Regular Expressions

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

    Regular Expressions

    $ in RegExp means the end of a string. So if the ValidationExpre ssion
    for a RegularExpressi onValidator which validates a TextBox is "c
    $" (without the double quotes), shouldn't input strings 'abc', '23pc',
    'c9mccc' (all without the single quotes) evaluate to True BUT it
    doesn't. In fact, these strings evaluate to False. Only the string
    'c' (again without the single quotes) evaluates to True.

    If I am not mistaken, "c$" means that any string (irrespective of its
    length) will evaluate to True provided the last character in the
    string is 'c' (without the single quotes). Or have I got it wrong? If
    so, please correct me.

    Thanks,

    Ron
  • David Wier

    #2
    Re: Regular Expressions

    I don't use them very often, but I thought it was the other way around - -
    $c

    David Wier

    http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with no
    bloated markup


    "RN1" <rn5a@rediffmai l.comwrote in message
    news:f82aaa7f-ff2d-49b4-9ab0-698846bc959b@t5 4g2000hsg.googl egroups.com...
    >$ in RegExp means the end of a string. So if the ValidationExpre ssion
    for a RegularExpressi onValidator which validates a TextBox is "c
    $" (without the double quotes), shouldn't input strings 'abc', '23pc',
    'c9mccc' (all without the single quotes) evaluate to True BUT it
    doesn't. In fact, these strings evaluate to False. Only the string
    'c' (again without the single quotes) evaluates to True.
    >
    If I am not mistaken, "c$" means that any string (irrespective of its
    length) will evaluate to True provided the last character in the
    string is 'c' (without the single quotes). Or have I got it wrong? If
    so, please correct me.
    >
    Thanks,
    >
    Ron


    Comment

    • Mick Wilson

      #3
      Re: Regular Expressions

      Try this site for help:



      It gives some explanation on what the various characters mean as well
      as a good tool to use for building a regular expression.

      If you want any string ending in 'c', use ^.*c$



      Comment

      • RN1

        #4
        Re: Regular Expressions

        On Mar 28, 1:37 am, Mick Wilson <mick.wil...@gm ail.comwrote:
        Try this site for help:
        >

        >
        It gives some explanation on what the various characters mean as well
        as a good tool to use for building a regular expression.
        >
        If you want any string ending in 'c', use ^.*c$
        Thanks, my dear friends, for your inputs. I knew that "c$" would allow
        only "c" & nothing else (i.e. the length of the string can be 1 & 1
        only, not more than that) but in the article at
        http://www.regular-expressions.info/anchors.html, it is stated that

        -----------------------------------------
        c$ matches c in abc
        -----------------------------------------

        (which is the 11th line in that article considering that the line
        after the heading "Start of String and End of String Anchors" is the
        1st line). Isn't that statement wrong? Yes...."c$" matches "c" in the
        string "abc" but the string "abc" evaluates to False when the RegEx is
        "c$". Or have I misinterpreted the term "matches" used in that
        article?

        That is what confused me.....

        Ron

        Comment

        • =?Utf-8?B?YnJ1Y2UgYmFya2Vy?=

          #5
          RE: Regular Expressions

          in a regular expression c$ will match abc (the capture will be c), but will
          not with the RegularExpressi onValidator. the RegularExpressi onValidator
          compares the controls value to the match, so it is the same as if your
          expression was:

          ^c$$

          to just check for an ending c with the RegularExpressi onValidator you would
          use:

          .*c

          which will be treated like

          ^.*c$


          -- bruce (sqlwork.com)


          "RN1" wrote:
          $ in RegExp means the end of a string. So if the ValidationExpre ssion
          for a RegularExpressi onValidator which validates a TextBox is "c
          $" (without the double quotes), shouldn't input strings 'abc', '23pc',
          'c9mccc' (all without the single quotes) evaluate to True BUT it
          doesn't. In fact, these strings evaluate to False. Only the string
          'c' (again without the single quotes) evaluates to True.
          >
          If I am not mistaken, "c$" means that any string (irrespective of its
          length) will evaluate to True provided the last character in the
          string is 'c' (without the single quotes). Or have I got it wrong? If
          so, please correct me.
          >
          Thanks,
          >
          Ron
          >

          Comment

          Working...