Weird Javascript Regex Replace Backreference Behavior
- by arshaw
why does the following js expression:
"test1 foo bar test2".replace(/foo.bar/, "$'")
result in the following string?
"test1 test2 test2"
is the $' in the replace string some sort of control code for including everything after the match???
this behavior was screwing with me most of the day. can anyone explain this?
thanks a lot
ps- this is the case in all browsers i've tested