quick question on javascript .replace

  • Thread starter Thread starter Paul W
  • Start date Start date
P

Paul W

Hi I need to replace every "||" (double pipes) in a string with "|" (single
pipe).

I'm having problems with the reg. expression (is "|" some kind of special
character?),

so tmpstr=myvar.replace("||/g","|") doesn't work.

Advise please,

Thanks, Paul.
 
in regular expressions yes, you need to quote it and build a valid RegEx

tmpstr=myvar.replace(/\|\|/g,"|");

-- bruce (sqlwork.com)


| Hi I need to replace every "||" (double pipes) in a string with "|"
(single
| pipe).
|
| I'm having problems with the reg. expression (is "|" some kind of special
| character?),
|
| so tmpstr=myvar.replace("||/g","|") doesn't work.
|
| Advise please,
|
| Thanks, Paul.
|
|
 
Back
Top