tags:

views:

41

answers:

3

Hi,

How can I write a regular expression to match "SS19100025" type of string?

Start with 2 "S" then "191" then after 5 digit number.

Thanks a lot, devweb

+3  A: 
/SS191\d{5}/

Edit: If you're looking to learn Regex, may I recommend Mastering Regular Expressions. It is a fantastic book and has helped me tremendously. Also answering questions on SO is another great way to learn regex.

Gavin Miller
Thanks it works! I need to learn this things soon!
Will sure take a look at this book. Thanks a lot.
A: 

You can try "SS191\d{5}"

Rob
Thanks to you too!
+2  A: 

this should work:

/^SS191[0-9]{5}$/
Phil Vollhardt
you may already know this but, you can use the \d flag in place of [0-9]
chollida
Phil's is better. It insures that there is nothing before or after the desired string.
Rob
thanks chollida.
Phil Vollhardt