regular expression

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • James G. Braum

    regular expression

    Can someone tell me what this regular expression is matching?

    /\s*([A-Za-z0-9_\u00C0-\u00FF]+\*)|([A-Za-z0-9_\u00C0-\u00FF]+)|(["][^"]*["]
    )|([\(\)])\s*/



  • Andrew Urquhart

    #2
    Re: regular expression

    *James G. Braum* wrote:[color=blue]
    > Can someone tell me what this regular expression is matching?
    >
    >[/color]
    /\s*([A-Za-z0-9_\u00C0-\u00FF]+\*)|([A-Za-z0-9_\u00C0-\u00FF]+)|(["][^"]
    *["][color=blue]
    > )|([\(\)])\s*/[/color]

    Not sure if you're having a laugh, but anyhoo:

    zero or more white space characters then store matches to one or more of
    any of these characters: A to Z regardless of case, 0 to 9 or UTF-16
    characters represented in hexadecimal character codes by 00C0 to 00FF,
    all followed by a single asterisk

    or

    store matches to one or more of any of these characters: A to Z
    regardless of case, 0 to 9 or UTF-16 characters represented in
    hexadecimal character codes by 00C0 to 00FF

    or

    store matches to " followed by zero or more characters that are not "
    followed by a "

    or

    store matches to either an opening or closing round bracket that is
    followed by zero or more white space characters


    NB: There's significant scope for improvement, it's a rather inefficient
    regular expression.
    --
    Andrew Urquhart
    - FAQ: www.jibbering.com/faq/
    - Archive: www.google.com/groups?q=comp.lang.javascript
    - My reply address is invalid, use: www.andrewu.co.uk/contact/


    Comment

    • Andrew Urquhart

      #3
      Re: regular expression

      *Andrew Urquhart* wrote:
      Oh dear, I omitted the underscores, a correction follows:

      [snip][color=blue]
      > zero or more white space characters then store matches to one or more
      > of any of these characters: A to Z regardless of case, 0 to 9 or[/color]

      an underscore or
      [color=blue]
      > UTF-16 characters represented in hexadecimal character codes by 00C0
      > to 00FF, all followed by a single asterisk
      >
      > or
      >
      > store matches to one or more of any of these characters: A to Z
      > regardless of case, 0 to 9 or[/color]

      an underscore or
      [color=blue]
      > UTF-16 characters represented in
      > hexadecimal character codes by 00C0 to 00FF[/color]
      [snip]
      --
      Andrew Urquhart
      - My reply address is invalid, use: www.andrewu.co.uk/contact/


      Comment

      • Thomas 'PointedEars' Lahn

        #4
        Re: regular expression

        James G. Braum wrote:[color=blue]
        > Can someone tell me what this regular expression is matching?
        >
        > /\s*([A-Za-z0-9_\u00C0-\u00FF]+\*)|([A-Za-z0-9_\u00C0-\u00FF]+)|(["][^"]*["]
        > )|([\(\)])\s*/[/color]

        The same as

        /\s*(([0-9a-z_\u00C0-\u00FF]+)\*)|("[^"]*")|([\(\)])\s*/i

        But $1 and $2 (and RegExp.exec(... )[1] and RegExp.exec(... )[2]
        respectively) need to be exchanged then.

        <http://devedge.netscap e.com/library/manuals/2000/javascript/1.5/reference/regexp.html#119 3136>


        PointedEars

        Comment

        • Thomas 'PointedEars' Lahn

          #5
          Re: regular expression

          James G. Braum wrote:[color=blue]
          > Can someone tell me what this regular expression is matching?
          >
          > /\s*([A-Za-z0-9_\u00C0-\u00FF]+\*)|([A-Za-z0-9_\u00C0-\u00FF]+)|(["][^"]*["]
          > )|([\(\)])\s*/[/color]

          The same as

          /\s*(([0-9a-z_\u00C0-\u00FF]+)\*)|("[^"]*")|([\(\)])\s*/i

          See
          <http://devedge.netscap e.com/library/manuals/2000/javascript/1.5/reference/regexp.html#119 3136>


          PointedEars

          Comment

          Working...