regular expression to check number, symbol and alphabet

Hi Experts,
any one know how to user regular expression to check whether a string contain number, symbol and alphabet ?

Who is Participating?
to check for at least one symbol,

to check for all characters must be symbol,

to check for at least one number
Note: instead of 0-9 you can use \d for numbers.

to check for all characters must be number,
Note: instead of 0-9 you can use \d for numbers.

to check for at least one alphabet

to check for all characters must be alphabet
well, you can use this site to help you in REGEX Search and Testing:

for number check you can use: ^\d*$
for symbol its a bit more complex - i will need to know the Symbols to help you build that one.
for alphabet you can use : [-'a-zA-Z]

hope this helps
Reza RadConsultant, TrainerCommented:
Regex objNaturalPattern=new Regex("0*[1-9][0-9]*");
return objNaturalPattern.IsMatch(strNumber);

this is example for number patterns
but you can see list of all patterns in this attachements

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

mkdev2009Author Commented:
Thanks for reply.
The regular expression is actually want to validate the password that user create.
The password that user created must contain alphabet, number and symbols.

anyway we can do it in one regular expression?

here is all in single regex. But I don't know what else could be other than symbol, alphabet and numbers???


Note:: Space is not considered.

Open in new window

I think you need to escape the 1st slash :


Personally I would not allow so many types of symbols in a password. i'd stick to letters numbers "_" and "-"
Then the regex would be :


4-16 also enforces the length to be between 4 and 16 chars.
>>I think you need to escape the 1st slash :
You don't need to escape that one. It is the actual regex with proper escape.

Depending on your programming language, you may need to escape characters. That case you have to escape all back slashes for that regex, not only the first one.
You do not need to escape "\" when it's inside " [ ] " ?

Now I got what makes the confusion, you are right from your point of view.

In perl/php the regex can be written inside the /../ and most of the people use that one.  for example

so mine one will be as below after inside //

as my regex is inside the //, that's why i was escaping the forward slash with back slash means \/
Aha, I am not a perl guy :)
When I need scripting to mild applications I use TCL.

And for bigger stuff, C#
But I have yet to practice regex in C#.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.