我正在尝试构建一些正则表达式来验证一些文本框控件.我做了一些研究和测试,但不能让这个工作.我试图创建正则表达式的示例如下:
分别为1和5,我用过
([0-9]|[0-9]\d|45)$
([0-9]|[0-9]\d|1500000)$
Run Code Online (Sandbox Code Playgroud)
我遇到问题的第一个是年龄范围16-65(含),我想要没有小数位.在这里发帖后(正则表达式允许数字介于-90.0和+90.0之间)我以为我可以使用逻辑并让它得到怀疑,但不能!
我得到的表达是:
(\d|([1-6][6-4]))|65
Run Code Online (Sandbox Code Playgroud)
有人可以告诉我,我误解了这个!对上述其他例子的任何帮助都将受到热烈欢迎.
我有一个代码块来处理我的应用程序中的异常,它使用if/else块来获取消息内容.
我的代码如下:
// define variable to hold exceptions...
var exceptionMessage = new StringBuilder();
// based on the exception type...
if (expType == typeof(EntityValidationException))
{
// append the relevant message to the text...
exceptionMessage.Append(exception.InnerException.Message);
}
else if (expType == typeof(ValidationException))
{
// This is the type of error generated when entities are validated
var validationException = (ValidationException)exception;
exceptionMessage.Append(validationException.InnerException.Message);
}
else if (expType == typeof(DomainSecurityException))
{
// These are security breaches
var domainSecurityException = (DomainSecurityException)exception;
exceptionMessage.Append(domainSecurityException.InnerException.Message);
}
else if (expType == typeof(DomainInternalMessageException)) …Run Code Online (Sandbox Code Playgroud)