Saturday 15 June 2013

javascript - regexp to replace start/end symbols multiple times across the string -


As a newbie for regexp, I am not able to create regexp to complete the following tasks:

String:

  (q [1] = "one" and q [2] = "two")   

desired Results:

  (q [1] .indexOf ("one") and q [2] .indexOf ("two"))   

Regexp with = .indexOf (" combinations with any character, with " with ")

thanks

  var str = '(q [1] = "one "And q [2] =" two ") ';  str = Str.replace (/ = ("[^" + ") / g, '.indexOf ($ 1)')   

this set

  (Q [1] .indexOf ("a") and q [2] .indexOf ("two"))    

No comments:

Post a Comment