Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regular expression groups for multiple matches in javascript

i am using a regular expression: pattern=/([a-zA-Z0-9_\.].*?)=(.*?);/g; which has more than one match in the text i use. Now i want the content which is after "=" . I used RegExp.$2 but it gives only one value. Please help me for getting the value after "=" in all matches available.

like image 606
user1275375 Avatar asked Mar 20 '12 04:03

user1275375


1 Answers

You have to iterate through matches in a while loop:

var match = null;
while (match = pattern.exec(script_txt)) {
    // Do something with match[2]
}
like image 82
mathematical.coffee Avatar answered Nov 03 '22 02:11

mathematical.coffee