What does this represent in regularexpession validator control

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cmrhema
    Contributor
    • Jan 2007
    • 375

    What does this represent in regularexpession validator control

    Hi
    while debugging a code i found a Regular expression validator control having a property as below
    ValidationExpre ssion="[\w\ .-]*"

    Can any one please let me know what does this stand for.

    I am using C# and asp.net.

    regards
    cmrhema
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by cmrhema
    Hi
    while debugging a code i found a Regular expression validator control having a property as below
    ValidationExpre ssion="[\w\ .-]*"

    Can any one please let me know what does this stand for.

    I am using C# and asp.net.

    regards
    cmrhema
    Is that a space between \ and . or was that added by the forum software?
    If there is no space then that should match any words (letters and digits) which are allowed to start with and contain a dot (.) or a hyphen(-). No input is also matched.

    Comment

    • cmrhema
      Contributor
      • Jan 2007
      • 375

      #3
      Originally posted by r035198x
      Is that a space between \ and . or was that added by the forum software?
      If there is no space then that should match any words (letters and digits) which are allowed to start with and contain a dot (.) or a hyphen(-). No input is also matched.
      Many thanks for the reply

      There was a space betweeen the \ and .
      In another expression it was as below
      ValidationExpre ssion="[\w\-]*"

      Can you please be more precise

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by cmrhema
        ...

        Can you please be more precise
        The [] surround a character class. The * says zero or more times.
        So []* says whatever is in the [] can repeat itself zero or more times.
        Now coming to what's in the [] , the \w\ represents a word (combination of characters and digits) and the - since it appears at the end represents itself rather than specifies a range (as it would do in a-e).

        Comment

        • cmrhema
          Contributor
          • Jan 2007
          • 375

          #5
          Originally posted by r035198x
          The [] surround a character class. The * says zero or more times.
          So []* says whatever is in the [] can repeat itself zero or more times.
          Now coming to what's in the [] , the \w\ represents a word (combination of characters and digits) and the - since it appears at the end represents itself rather than specifies a range (as it would do in a-e).
          many many thanks for the answer

          Comment

          • TRScheel
            Recognized Expert Contributor
            • Apr 2007
            • 638

            #6
            Originally posted by cmrhema
            many many thanks for the answer
            I personally hate regular expressions so I use this

            Comment

            Working...