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:

  obj = values.replace (/ {name} (. *?) {\ / Name} /, 'igm');   

Regexp object:

  again = '\ / {' + id_name + '} (. *?) {\\ /' + id_name + ' } \ / '; Regexp = New RegExp (again, 'igm'); Obj = values.replace (regexp, vals); Thanks in advance   

You / and if you build regex through the constructor You are not required to avoid that character:

  re = '{' + id_name + '} (. *?) {/' + Id_name + '}';    

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -