quote:
Originally posted by Ezra
code:
stringObj.replace(/^(.+)(\?)$/i, \1..\2)
You forgot the "" around the second parameter. The first is a regular expression object and is totally correct, but the second is a string. Also, the regular expression can be lots and lots simpler. Therefore, the right way would be:
code:
stringObj.replace(/\?$/, "..?");
Here, I don't let it capture everything before the question mark because it simply isn't needed. This gives you a much easier to understand regular expression without the need of inserting captured parameters!
Because remember to KISS! (Keep It Short and Simple)