0

Possible Duplicate:
jQuery find/replace without changing original text

I have the following RegEx but I am getting a JS error

RegEx:

$("#construct_version").html(
   new RegExp("(" + selection + ")", "g"),
   $("$1").wrap(childElements[child]));

JS Error: Uncaught Syntax error, unrecognized expression: $1

This questions references this other question: jQuery find/replace without changing original text

Community
  • 1
  • 1
dennismonsewicz
  • 24,322
  • 31
  • 111
  • 183
  • Can you give some detail on what you expected it to do? – Daniel Mendel Oct 30 '10 at 19:45
  • @Daniel, Sorry, I am searching through a string for a particular string and wrapping the found string with an element in my childElements array – dennismonsewicz Oct 30 '10 at 19:47
  • The code doesn't make sense... what are you trying to do? :) – Vivin Paliath Oct 30 '10 at 19:49
  • @Dennis The same as in your [other question](http://stackoverflow.com/questions/4060056/jquery-find-replace-without-changing-original-text)? – lonesomeday Oct 30 '10 at 19:49
  • @lonesomeday, yes, I opened a new question so it could be found easier in searches – dennismonsewicz Oct 30 '10 at 19:50
  • 1
    It's hard to tell what you're trying to do, but it's just wrong. You first have to figure out what string you want to search for the regular expression in, and then you'll want to call "replace" on the string, with that RegExp object as the first parameter. Then you can extract that target string. Now, as to wrapping it in something, well I can't really say because you have not provided enough detail and context. – Pointy Oct 30 '10 at 19:50
  • 2
    Don't keep asking the same question over and over. Go back to the original question and add detail. You already got a good answer from one of the most senior JavaScript experts on Stackoverflow. – Pointy Oct 30 '10 at 19:52
  • "jQuery RegEx Problems" is **easier** to find than "jQuery find/replace without changing original text"?! What a crazy mixed up world we live in. – Quentin Oct 30 '10 at 19:53

0 Answers0