Results 1 to 3 of 3

Thread: [RESOLVED] Regexp

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2010
    Posts
    8

    Resolved [RESOLVED] Regexp

    Hello,

    This is the code:

    String ": this the first "
    String "this is 7777 7777 7777 7777"

    If Not aline.StartsWith(":") Then

    Dim pattern2 As String = "[0-9]{4}\s[0-9]{4}\s[0-9]{4}\s[0-9]{4}"
    Dim rg2 As Regex = New Regex(pattern2)
    If Regex.IsMatch(aline, pattern2) Then
    aline = Regex.Replace(aline, pattern2, "REPLACE")
    End If

    End If
    wr.WriteLine(aline)
    What is the regex to delete the space between: 7777 7777 7777 7777
    Thank you in advance for your reply.

    Leo

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,423

    Re: Regexp

    try this:

    vb Code:
    1. Dim testStr As String = "this is 7777 7777 7777 7777"
    2.  
    3. Dim rx As New Regex("[0-9]{4}\s[0-9]{4}\s[0-9]{4}\s[0-9]{4}")
    4. MsgBox(Regex.Replace(rx.Match(testStr).Value, " ", ""))

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2010
    Posts
    8

    Re: Regexp

    Hi Paul,

    It works, thank you.

    Regards,

    Leo

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