regex - Simple JavaScript Regular Expression -


i'm sure simple haven't been able create 1 works.

i need regular expression extract 1 or 2 digit number 1-13 string such "(11)" or "(3)"

thanks :)

result = subject.match(/\b(?:1[0-3]|0?[1-9])\b/); 

will match 2 digit number between 1 , 13, wherever may (as long it's not part of longer number or within word).

if want hard-code parentheses, it's

result = subject.match(/\((?:1[0-3]|0?[1-9])\)/); 

and if want find more 1 match in single string, use g modifier (after last slash).


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -