I need to find all substrings from a string that starting with a given string following with a left bracket and then any legal literal and then the right bracket. For example, a string is abcd(xyz)efcd(opq), I want to a function that returns "cd(xyz)" and "cd(opq)". I wrote a regular expression, but it returns only cd( and cd(...
+4
A:
The regex is:
/cd\([^\)]*\)/g
Try:
var reg = /cd\([^\)]*\)/g;
var match;
while(match = reg.exec(str))
{
...
}
Matthew Flaschen
2010-06-12 00:08:29