Click here to Skip to main content
15,886,689 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i need a regex to validate the Person Home address that includs all alphanumeric and special characters with a limit of 1 - 150.
i.e
House # 20-H, Street # 10, F-8/3 Islamabad.
Ph: +92-51-2852662 (Exchange)
Fax : +92-51-2852663
E-mail: info@pmln.org

I have tried this, but it is not working...as it only accpet characters,
JavaScript
^[a-zA-Z''-'\s]{1,150}$
Posted
Updated 11-May-14 9:13am
v2
Comments
CHill60 11-May-14 17:03pm    
Why use a regex? Sounds like all you have to do is limit the length to 1 to 150
Muhammad Taqi Hassan Bukhari 11-May-14 18:42pm    
i have to do both
syed shanu 11-May-14 20:52pm    
Chk this Link :
http://www.aspsnippets.com/Articles/Implement-Password-Policy-using-Regular-Expressions-and-ASPNet-RegularExpression-Validator.aspx

1 solution

If you insist on Regex, try this:
^.{1,150}$

Remember to trim the string from leading and trailing space before matching.
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900