Results 1 to 2 of 2

Thread: RegEx: Replace all BUT line breaks

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2007
    Posts
    5

    RegEx: Replace all BUT line breaks

    Code:
    Dim reg As System.Text.RegularExpressions.Regex
    Me.lblAnswer.Text = System.Text.RegularExpressions.Regex.Replace(lblAnswer.Text, ".", "*")
    Okay, so the "." is supposed to convert everything BUT line breaks. Well it converts line breaks as well... how to change so it does not replace line breaks with "*"?

  2. #2
    Registered User nmadd's Avatar
    Join Date
    Jun 2007
    Location
    U.S.A.
    Posts
    1,676

    Re: RegEx: Replace all BUT line breaks

    How about this?
    vb.net Code:
    1. Dim txt As String = "blahblah" & Environment.NewLine & "blah blah bleh"
    2. Dim exp As String = "[^\r\n]"
    3. Dim newTxt As String = Regex.Replace(txt, exp, "*")
    4. MessageBox.Show(newTxt)

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