Regular expression for allowed numbers

I want to check the following with regex

{Today,Format}

      

Today it will remain as it is. Instead of formatting, we can allow numbers from 0 to 12.

eg: we have to allow

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

      

and also allow

{Today,}
{Today,Format}

      

Please help me and also call me on some site to develop regex skills.

0


source to share


4 answers


\{Today,(\d|1[012]|Format)?\}

      

Value:



  • Open curly braces;
  • 'Today';
  • Optional one of the following: digit (0-9), 1, then 0, 1, or 2 (10,11,12), "Format"; and then
  • Close curly braces.

In terms of resources, I can recommend this site in regular expressions and the book Mastering Regular Expressions .

+18


source


txt2re.com is a brilliant web-based regular expression generator ...



+4


source


You can also find this list of regular expression programs . Rubular is my favorite.

0


source


This is a short cheat sheet for regexp.

0


source







All Articles