Link to home
Start Free TrialLog in
Avatar of MoniMatthews
MoniMatthewsFlag for United States of America

asked on

How do I add a match for a period in a Regular Expression Validator

I have an expression: [a-zA-Z\s0-9]{0,500}, it as long as I don't enter a period character. How do I add a the option for a period character?
<asp:RegularExpressionValidator ID="revSN" runat="server" ControlToValidate="txtSN" ErrorMessage="Please eneter a vaild information in this field." ValidationExpression="[a-zA-Z\s0-9]{0,500}"></asp:RegularExpressionValidator>

Open in new window

Avatar of mrjoltcola
mrjoltcola
Flag of United States of America image

Escape it with a \

\.

or put inside a range [.], inside the [] the . dot is literal
ASKER CERTIFIED SOLUTION
Avatar of mrjoltcola
mrjoltcola
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of evilrix
Rather than

[a-zA-Z\s0-9.]{0,500}

You could trye

[\d\w\s.]{0,500}

\d, \w and \s      Shorthand character classes matching digits, word characters, and whitespace. Can be used inside and outside character classes.

http://www.regular-expressions.info/reference.html
Avatar of MoniMatthews

ASKER

Thanks