quick question on javascript .replace

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Paul W

    quick question on javascript .replace

    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.re place("||/g","|") doesn't work.

    Advise please,

    Thanks, Paul.


  • bruce barker

    #2
    Re: quick question on javascript .replace

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

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

    -- bruce (sqlwork.com)


    "Paul W" <qqq@qqq.com> wrote in message
    news:%23MhyySNz EHA.2572@tk2msf tngp13.phx.gbl. ..
    | 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.re place("||/g","|") doesn't work.
    |
    | Advise please,
    |
    | Thanks, Paul.
    |
    |


    Comment

    Working...