Reputation: 27
Here are my two reg expressions. The first one seems to match my case insensitive string exactly, but the second one has a space and isn't working.
^([wW][eE][eE][kK][5][0][0])$
^([wW][eE][eE][kK][/s][5][0][0])$
So I have two problems:
1) What do I change so that my first reg expression in my asp RegularExpressionValidator will not match my "Week500" case insensitive, entire string? I only want it to fire if this entire string (albeit case insensitive) is matched. Currently this reg expression is doing the opposite of what I need.
2) I also need this same change for my second reg expression in my second asp RegularExpressionValidator. However, it has a space in a specific place in the string "Week 500".
Here are the complete tags for my two RegularExpressionValidators on my asp page:
<asp:RegularExpressionValidator ID="revPrevEventNameDup" runat="server" ControlToValidate="txtGenerateEventsPreviewEventName" EnableClientScript="true" ErrorMessage="Dup Name" Display="Dynamic" ValidationExpression="^([wW][eE][eE][kK][5][0][0])$" ValidationGroup="GenerateEventsPreviewValidation" />
<asp:RegularExpressionValidator ID="revPrevEventNameDup" runat="server" ControlToValidate="txtGenerateEventsPreviewEventName" EnableClientScript="true" ErrorMessage="Dup Label" Display="Dynamic" ValidationExpression="^([wW][eE][eE][kK][5][0][0])$" ValidationGroup="GenerateEventsPreviewValidation" />
Thank you in advance for your help.
++++++++++++++++++++++++++++++++++++++++++
I'm new so I can't answer my own question, so it suggested I put the answer here...
Thank you all for the string help!!
You're all GREAT!!
Here:
ASP.NET RegularExpressionValidator, validate on a non-match?
I found that I had to add:
^(?!
to the front and:
$).*$
to the end to get the validate on a non-match.
So here are my two finial RegularExpressionValidators for my asp page that work GREAT!!
ValidationExpression="^(?!([wW][eE][eE][kK]500)$).*$"
ValidationExpression="^(?!([wW][eE][eE][kK] 500)$).*$"
THANK YOU!!!
Upvotes: 2
Views: 1108
Reputation: 43023
Can you try this regex ? ^([wW][eE][eE][kK][\s][5][0][0])$
I change / to \
Upvotes: 0
Reputation: 3587
The white-space matching regular expression is \s
, not /s
.
^([wW][eE][eE][kK][\s][5][0][0])$
If all you need is a space, just type it.
^([wW][eE][eE][kK] [5][0][0])$
And, if you want to match a single character, just type those too, unless they are special:
^([wW][eE][eE][kK] 500)$
And in all cases, if \
is special to your string holder, you may need to escape the escape character, using \\
.
Upvotes: 2