More regex problems

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Christopher Benson-Manica

    More regex problems

    These give me "invalid character". Why? Is it the ampersand or the
    <>?

    source=source.r eplace( /\</g, "&lt;" );
    source=source.r eplace /\>/g, "&gt;" );



    --
    Christopher Benson-Manica | I *should* know what I'm talking about - if I
    ataru(at)cybers pace.org | don't, I need to know. Flames welcome.
  • Evertjan.

    #2
    Re: More regex problems

    Christopher Benson-Manica wrote on 03 dec 2004 in comp.lang.javas cript:
    [color=blue]
    > These give me "invalid character". Why? Is it the ampersand or the
    > <>?
    >
    > source=source.r eplace( /\</g, "&lt;" );
    > source=source.r eplace /\>/g, "&gt;" );
    >[/color]

    You miss the ( in the second example
    You don't need to escape the < and >

    Why ask? Did you try to temporarily removing the & ?

    Please try first and ask later.

    Comment

    • Christopher Benson-Manica

      #3
      Re: More regex problems

      Evertjan. <exjxw.hannivoo rt@interxnl.net > spoke thus:
      [color=blue]
      > You miss the ( in the second example[/color]

      Today's been a bad day; can't believe I missed something so simple.
      Sorry, and thanks.

      --
      Christopher Benson-Manica | I *should* know what I'm talking about - if I
      ataru(at)cybers pace.org | don't, I need to know. Flames welcome.

      Comment

      Working...