Unicode characters in RegExp

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ron Brennan

    #1

    Unicode characters in RegExp

    I'm trying to test a character for not being uppercase, including Unicode
    Latin-1.

    The following JavaScript expression doesn't work. It is embedded in a
    servlet that targets IE 5 or later.

    if (/[^A-Z \u00C0-\u00D6 \u00D8-\u00DF]/.test(stest))

    Probably something obvious to those of you working with RegExp more than me.

    Thanks,
    Ron



  • Evertjan.

    #2
    Re: Unicode characters in RegExp

    Ron Brennan wrote on 21 nov 2004 in comp.lang.javas cript:
    [color=blue]
    > I'm trying to test a character for not being uppercase, including
    > Unicode Latin-1.
    >
    > The following JavaScript expression doesn't work. It is embedded in a
    > servlet that targets IE 5 or later.
    >
    > if (/[^A-Z \u00C0-\u00D6 \u00D8-\u00DF]/.test(stest))
    >
    > Probably something obvious to those of you working with RegExp more
    > than me.[/color]

    Works fine here [btw, leave the spaces out]

    stest='é'
    alert(/[^A-Z\u00C0-\u00D6\u00D8-\u00DF]/.test(stest))

    stest='É'
    alert(/[^A-Z\u00C0-\u00D6\u00D8-\u00DF]/.test(stest))

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress,
    but let us keep the discussions in the newsgroup)

    Comment

    • Ron Brennan

      #3
      Re: Unicode characters in RegExp

      > Works fine here [btw, leave the spaces out][color=blue]
      >
      > stest='é'
      > alert(/[^A-Z\u00C0-\u00D6\u00D8-\u00DF]/.test(stest))
      >
      > stest='É'
      > alert(/[^A-Z\u00C0-\u00D6\u00D8-\u00DF]/.test(stest))
      >
      > --
      > Evertjan.
      > The Netherlands.
      > (Please change the x'es to dots in my emailaddress,
      > but let us keep the discussions in the newsgroup)[/color]

      Works fine here too, once I commented out the part of the program that was
      causing the problem. :)

      Thanks again Evertjan,
      Ron



      Comment

      Working...