Matchtext / Regular expressions: searching multiple lines

Ken Ray kray at sonsothunder.com
Thu Feb 13 10:50:01 EST 2003


Guys, the matchText *will* search multiple lines, but because MC
supports PCRE not Perl's RegEx, things are a little different. For the
full skinny, go to http://www.pcre.org/man.txt. But the basic is to use
"(?s)" before your match expression, and to make it not greedy, add "?".
For example, here's a search I did recently, looking for data between
<title></title> tags in an XML document. The match below will find the
first match:

on CheckIt pXMLData
  local tTitle
  get matchText(pXMLData,"(?s)<title>(.*?)</title>",tTitle)
  if it is true then
    answer "The title is: " & tTitle
  end if
end CheckIt

Hope this helps,

Ken Ray
Sons of Thunder Software
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/

----- Original Message -----
From: <xbury.cs at clearstream.com>
To: <metacard at lists.runrev.com>
Sent: Thursday, February 13, 2003 8:01 AM
Subject: RE: Matchtext / Regular expressions: searching multiple lines


> wont work. I had the same problem before but this is a "greedy"
grep...
>
> you can use \n but it's not exactly accurate...
>
> what's up Dave?
> Tried my script editor yet? ;))
>
> -----Original Message-----
> From: David Bovill [mailto:david at anon.nu]
> Sent: Thursday, February 13, 2003 04:20
> To: metacard at lists.runrev.com
> Subject: Matchtext / Regular expressions: searching multiple lines
>
>
> Having problems figuring out how to set the matchText regular
expressions to
>
> search multiple lines: the perl reference inclded in the Readme file
talks
> about using "/s" as a modifier to achieve this - but stuck there?
>
> thanx
> _______________________________________________
> metacard mailing list
> metacard at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/metacard
>
>
> Visit us at http://www.clearstream.com
>
> IMPORTANT MESSAGE
>
> Internet communications are not secure and therefore Clearstream
International does not accept legal responsibility for the contents of
this message.
>
> The information contained in this e-mail is confidential and may be
legally privileged. It is intended solely for the addressee. If you are
not the intended recipient, any disclosure, copying, distribution or any
action taken or omitted to be taken in reliance on it, is prohibited and
may be unlawful. Any views expressed in this e-mail are those of the
individual sender, except where the sender specifically states them to
be the views of Clearstream International or of any of its affiliates or
subsidiaries.
>
> END OF DISCLAIMER
> _______________________________________________
> metacard mailing list
> metacard at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/metacard
>




More information about the metacard mailing list