最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Regular expression for allow only numbers - Stack Overflow

programmeradmin8浏览0评论

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.

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.

Share Improve this question edited Feb 5, 2010 at 1:43 cletus 625k169 gold badges919 silver badges945 bronze badges asked Dec 23, 2008 at 11:16 praveenjayapalpraveenjayapal 38.5k31 gold badges74 silver badges74 bronze badges 1
  • Just FYI, 'regex' is a far more mon tag than 'regular-expression' or similar. – cletus Commented Dec 23, 2008 at 12:01
Add a ment  | 

4 Answers 4

Reset to default 18
\{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 remend this site on regular expressions and the book Mastering Regular Expressions.

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

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

This is a short cheat sheet to regex.

发布评论

评论列表(0)

  1. 暂无评论