Results 1 to 3 of 3

Thread: Regular expressions

  1. #1

    Thread Starter
    Frenzied Member Asgorath's Avatar
    Join Date
    Sep 2004
    Location
    Saturn
    Posts
    2,036

    Regular expressions

    Hi
    I need a regex to validate a string that must ends with "/" and 2 digits

    Examples

    "aaa/" not ok
    "aaa/0a" not ok
    "bdc/88" ok

    Thanks
    Jorge
    Last edited by Asgorath; May 5th, 2005 at 12:16 PM.
    "The dark side clouds everything. Impossible to see the future is."

  2. #2
    Addicted Member
    Join Date
    Jan 2005
    Posts
    136

    Re: Regular expressions

    VB Code:
    1. Dim tbox As TextBox = DirectCast(sender, TextBox)
    2.         If Regex.IsMatch(tbox.Text, "^([a-zA-Z]+)/([0-9]{2,2})$") = True Then
    3.         Else
    4.             MsgBox("Not valid String")
    5.         End If
    i assumed that the first part of the string contains only char not num

  3. #3

    Thread Starter
    Frenzied Member Asgorath's Avatar
    Join Date
    Sep 2004
    Location
    Saturn
    Posts
    2,036

    Re: Regular expressions

    Modified it slightly its working now

    VB Code:
    1. Dim tbox As TextBox = DirectCast(sender, TextBox)
    2.         If Regex.IsMatch(tbox.Text, "^([a-zA-Z0-9.]+)/([0-9]{2,2})$") = True Then
    3.         Else
    4.             MsgBox("Not valid String")
    5.         End If

    Thanks
    Jorge
    "The dark side clouds everything. Impossible to see the future is."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width