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

javascript - Iterate over array and calculate average values of array-parts -

iphone - Using nested NSDictionary with Picker -

objective c - Newbie question -multiple parameters -