views:

2934

answers:

5

I want to check the following with regular expression

{Today,Format}

Today - will be remains as it is. In the place of Format, we can allow the digits from 0 to 12.

for example: we have to allow

{Today,0}
{Today,1}
{Today,2}
...
{Today,12}

and also have to allow

{Today,}
{Today,Format}

Please help me and also refer me to some site to develop my regular expression skills.

+4  A: 

txt2re.com is a brilliant web-based regex generator...

flesh
+18  A: 
\{Today,(\d|1[012]|Format)?\}

Meaning:

  • Open curly brace;
  • 'Today,';
  • Optionally one of the following: a digit (0-9), 1 followed by 0, 1 or 2 (10,11,12), 'Format'; and then
  • Close curly brace.

As for resources I can recommend this site on regular expressions and the book Mastering Regular Expressions.

cletus
A: 

You might also find this list of regular expression software quite useful. Rubular is my favorite.

Yaser Sulaiman
A: 

This is a short cheat sheet to regex.

perfectDay
A: 

hi ,this is vamsi i want allow numeric numbers up to 10 characters.How can we write the regular expression format.plaese would you tell me.

Using Perl-style: \d{1,10}
Bklyn