Pattern Matching

E

Eric

I use RegEx to search pattern. Script works fine in the situation when
there is a colon after each word and it fetch the rest of the word from
that line. Now the pattern is in square bracket and i need help how to
change that line (sPattern =

"From\:\s*([\s\S]+?)[\r\n]+") so that it search pattern in a square
bracket and fetch the next line of that pattern.


Dim fso, fil, ts, sContents
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set fil = fso.getfile(server.mappath("myemails.txt"))
Set ts = fil.openastextstream(1)
sContents = ts.readall
sPattern = "From\:\s*([\s\S]+?)[\r\n]+"
Dim rx
Set rx = New RegExp
rx.Global = True
rx.IgnoreCase = True
rx.MultiLine = True
rx.Pattern = sPattern
Set mc = rx.Execute(sContents)
Set rm = mc.Item(0)
sFrom = rm.SubMatches(0)
response.write(sFrom)
ts.close
Set rx = nothing
Set ts = nothing
Set fil = nothing
Set fso = nothing


-----SAMPLE DATA--------
[Date]
Sat Aug 05 14:06:12 EDT 2006

[Novell ID]
NSMITH4

[Subject]
PPV / VOD Research - Dispute - 1st Time - 711579

[Customer's Name]
EDWARD CAMPBELL
 
K

Kevin Spencer

\[([^][]+)\]

Matches square brackets and anything between them. Puts the characters
between the square brackets into Group 1.

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Surgery

Expect the unaccepted.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Search text 1
Save data from text file into access 0
Read data from the email body 1
Error 0
Logical Error 1
Insert Data 2
Insert Data 0
Error 7

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top