Answer the question
In order to leave comments, you need to log in
How to properly declare a regular expression?
Here is the working code:
var regul = /(AAA|BBB|CCC|DDD)\(.*?\)/g;
var str = "one two 12AAA(CCC(C1_1);A1_1)dfg dfgdfgdfg,BBB(B1_1; B1_2) sfsgndf dfgnhjdfglkjdfg DDD(D1_1)";
var ARR = str.match( regul );
for(var i = 0; i < ARR.length; i++) {
console.log((i+1)+') '+ARR[i]);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question