Pattern Matching

Pattern Matching

am 08.08.2006 00:00:24 von 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

Re: Pattern Matching

am 08.08.2006 00:12:49 von reb01501

Eric wrote:
> I use RegEx to search pattern. Script works fine in the situation

Please do not multipost Eric. This is definitely not a database-related
question
so .asp.general was the perfect group in which to post it. Posting it
here as
well did not increase your chances of getting an answer (most of us
subscribe to both groups). On the contrary, if somebody had taken his
time
to answer it here, only to find that it was already resolved in the
other
group, that person may have been annoyed enough to ignore any future
posts
from you, thereby decreasing your chances of getting help in the future.

There are times when you will not be sure which group is most
appropriate,
and you will want to post a question to both groups. In that situation,
you
should use the cross-posting technique, rather than posting the same
message
multiple times. To crosspost, put a semicolon-delimited* list of the
newsgroups to which you wish to post in the To: header of your post and
post
it once. It, and any replies to it, will appear in all the newsgroups in
your list. So, if I reply in .asp.general, my reply will also appear
here in
..asp.db.

* ... or whatever delimiter is recognized by your news client
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.