Click here to Skip to main content
15,896,201 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello Everyone,

I have used following code to validate my password

C#
@"^[A-Z]{1}[a-z]+$"


Can anyone suggest changes ,I wish to include @ in my passwords

For name validation I have used

C#
"^[A-Z][a-zA-Z]*$")


I want to restrict entries like hsgetgsbs bhbahabb @hahaaj and so on.Can this be achieved with Regular expressions?.I want to achieve the same in fields like First Name Last Name and Username

For a 10 digit mobile number I used following

C#
@"^[1-9]\d{2}-[1-9]\d{2}-\d{4}$"
but didn't work.Can anyone suggest changes?

Thanks
Posted

1 solution

Password including "@":
@"^[A-Z]{1}[a-z@]+$"


The others we can't help with as we have no idea what restrictions you are tying to apply, and absolutely no idea what "didn't work" is supposed to mean...
 
Share this answer
 
Comments
vivek murli 26-Oct-14 13:11pm    
Thanks for replying Original Griff

I mean for Name Validation I used "^[A-Z][a-zA-Z]*$").Here I want to restrict entries like agavvsgsb or any other junk entry in Name Field.Is that possible to achieve?


In case of Phone Validation I used Regex @"^[1-9]\d{2}-[1-9]\d{2}-\d{4}$".I tried adding 10 digit mobile number but its not working.Please suggest changes to the regex so that I can add 10 digit Mobile number



Thanks
OriginalGriff 26-Oct-14 13:27pm    
The problem is that "entries like agavvsgsb or any other junk entry" is not anything a regrex can check. Is "Lloyd" meaningful? It's a valid name, as is "Vivek", or "Griff".
You can't check meaning with regexes - just text sequences.

And "it's not working" could mean anything!

[][]
vivek murli 26-Oct-14 23:36pm    
Thanks

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