I am trying to alert the numbers that fall within the parenthesis:
var str2 = "This is a string (3444343) with numbers.";
var patt2 = \((.*?)\);
alert(str2.match(patt2));
jsfiddle: http://jsfiddle.net/BinaryAcid/8nx9v/1/
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Solution
Based on your original question, this would do:
An updated jsFiddle example: http://jsfiddle.net/S99jd/
For your input string, it alerts
3444343(without parenthesis).Some Explanations
Your snippet needed:
/to create the regex,1, asmatch()returns an array of elements, where element at index0is the full match and following indexes correspond to the matching groups).For a lot more information and help on using regular expressions in JavaScript / ECMAScript, visit: http://www.regular-expressions.info/javascript.html