RegExp MultiLine Replace Not Working

TastyWheat

Registered User.
Local time
Today, 17:42
Joined
Dec 14, 2005
Messages
125
It might be my pattern that's wrong, rather than something being wrong with RegExp, but I'm unable to replace multiple lines of a string using one statement. Here's an example of my string:
Jane Doe

Marketing Manager

Good Foods Inc.


From: jdoe@goodfoods.com
Sent: Wednesday, April 08, 2009 1:20 PM
To: Bob White
Subject: Party
_____


When: 04/18/2009
Time: 6:30 PM
Where: Jim's Steakhouse

_____
I'm looking to remove everything above the first set of underscores (in red). Here's the code I've tried (seems to do nothing except remove the whitespace between "Party" and the first set of underscores):
Code:
Set RGX = New VBScript_RegExp_55.RegExp
RGX.IgnoreCase = True
RGX.MultiLine = True
RGX.Global = True
RGX.Pattern = "[.\r\n\W]*_____"
text = RGX.Replace(MailItem.Body, "_____")
 
Once again all I had to do was ask the question so I could figure it out myself. This code got me what I wanted:
Code:
RGX.MultiLine = True
RGX.Global = False
RGX.Pattern = "[\s\S]*?_____"
text = RGX.Replace(ITM.Body, "_____")
I thought that the '\W' or the '.' would've handled any kind of newline character, but apparently not. If you need any regular expression help I used http://regexpal.com to figure out my problem and it's very good. It even highlights the match as you type the pattern.
 

Users who are viewing this thread

Back
Top Bottom