Regualr expression for a string

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sdanda
    New Member
    • Oct 2007
    • 36

    Regualr expression for a string

    Hai, My string must be 3 characters.Firs t character must be integers in the range 1-9. and second character must be * and third character must be the number with in the range 0 to 9.
    I wrote this code to mathch this expression.
    Dim txt As Regex = New Regex("[^1-9][*][0-9]")
    but it does nt work.Can you give some idea?
  • shweta123
    Recognized Expert Contributor
    • Nov 2006
    • 692

    #2
    Hi,

    You can try the following regular expression :

    Dim options As RegexOptions = RegexOptions.No ne
    Dim regex As Regex = new Regex("^[0-9]\*[0-9]$", options)


    Originally posted by sdanda
    Hai, My string must be 3 characters.Firs t character must be integers in the range 1-9. and second character must be * and third character must be the number with in the range 0 to 9.
    I wrote this code to mathch this expression.
    Dim txt As Regex = New Regex("[^1-9][*][0-9]")
    but it does nt work.Can you give some idea?

    Comment

    • sdanda
      New Member
      • Oct 2007
      • 36

      #3
      Originally posted by shweta123
      Hi,

      You can try the following regular expression :

      Dim options As RegexOptions = RegexOptions.No ne
      Dim regex As Regex = new Regex("^[0-9]\*[0-9]$", options)
      Thanks a lot.I wasted so much time for this simple regular expression.Thak you.

      Comment

      Working...