regex - JavaScript/Jquery Dynamic RegExp generation -
I have searched this place a lot, and I'm working on my regular expression, but not dynamically.
id_name string that is selected dynamically, then regexp should change the match with a single variant, which is in "wals" for some reason, when I Without the variable regexp code, it works as a purpose, I think I can do something wrong with the conversion in a regexp object. Original String: Regexp object: You
obj = values.replace (/ {name} (. *?) {\ / Name} /, 'igm');
again = '\ / {' + id_name + '} (. *?) {\\ /' + id_name + ' } \ / '; Regexp = New RegExp (again, 'igm'); Obj = values.replace (regexp, vals); Thanks in advance
/ and if you build regex through the constructor You are not required to avoid that character:
re = '{' + id_name + '} (. *?) {/' + Id_name + '}';
Comments
Post a Comment