Results 1 to 3 of 3

Thread: [RESOLVED] RegEx / Multiline

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2005
    Location
    Alaska
    Posts
    435

    Resolved [RESOLVED] RegEx / Multiline

    Yet another RegEx question. I have a file that sometimes contains this exact set:

    Code:
    ExceptionData = {
    }
    Code:
    ErrorMsgs = {
    }
    I'm trying to make it so if either of those exactly match, to remove them from the string since it causes an error if they contain no data between the { }.

    I tried a few different methods, but I can seem to match it because the } is on a new line.

    Any ideas?

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

    Re: RegEx / Multiline

    try this:

    vb Code:
    1. Dim testStr As String = "ExceptionData = {" & Environment.NewLine & "}" & _
    2. Environment.NewLine & "ErrorMsgs = {" & Environment.NewLine & "}"
    3. testStr = Regex.Replace(testStr, "(ExceptionData|ErrorMsgs) = {\r\n}", "").Trim

    if it doesn't work, post the rest of the file you're working with. it should work as it is though.
    Last edited by .paul.; Apr 11th, 2009 at 05:04 PM.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2005
    Location
    Alaska
    Posts
    435

    Re: RegEx / Multiline

    Worked perfectly. Thanks!

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