find words from group of letters in a statement using regularexpression
-
Hi, i have the below code var copy = "CATCOMETACISTCASEATCORACT"; var reg = /(CAT)+/; var sd = copy.match(reg); sd returns me only array with values [CAT,CAT] but i need diff combinations like "CAT","CTA","TAC","ACT","ATC","TCA" wat should the exact regular expression for the above result...
-
Hi, i have the below code var copy = "CATCOMETACISTCASEATCORACT"; var reg = /(CAT)+/; var sd = copy.match(reg); sd returns me only array with values [CAT,CAT] but i need diff combinations like "CAT","CTA","TAC","ACT","ATC","TCA" wat should the exact regular expression for the above result...
Just added modifiers - 'i' for ignore case and 'g' for global search
var copy = "CATCOMETACISTCASEATCORACT";
var reg = /([CAT]){3}/ig;
var sd = copy.match(reg);Hope this may help you. Regards, Niral Soni
Thanks & Regards, Niral Soni
-
Just added modifiers - 'i' for ignore case and 'g' for global search
var copy = "CATCOMETACISTCASEATCORACT";
var reg = /([CAT]){3}/ig;
var sd = copy.match(reg);Hope this may help you. Regards, Niral Soni
Thanks & Regards, Niral Soni
Doesn't work. Your regex will accept "CCC" "CCA" "TTT" "ATT" etc, which is not what OP wants. Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012