regexp

Ken Ray kray at sonsothunder.com
Wed Jan 8 10:23:00 EST 2003


Sorry about that... hit the Send button too soon.

The key to remember in MC (after 2.4.2 where PCRE was added) is the modifier
"(?s)" which means to "treat the entire chunk of text as my string, ignoring
newlines". So if you want to get the chunk from the beginning of the "W" in
"Welcome" to the end ">" in "<!user-name>", you can use this:

-- I have your text snippet in field 1
on mouseUp
  local tStart,tEnd
  get matchChunk(fld 1,"(?s)(Welcome.*?<!user-name>)",tStart,tEnd)

  select char tStart to tEnd of fld 1
end mouseUp

Hope this helps!

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



----- Original Message -----
From: "andu" <undo at cloud9.net>
To: <metacard at lists.runrev.com>
Sent: Wednesday, January 08, 2003 6:15 AM
Subject: regexp


> I need some help with matchChunk(). Here's the problem, I need to parse
> html pages for a certain chunk and replace it with an other. Unfortunately
> I cant use the good old "replace x with y in z" because the chunk
sometimes
> is on one line other times on many.
> Here's an example:
>
>         <p><font face="Arial" size="2"><b>Welcome
>           <!user-name>
>
>           to our site</b></font> </p>
>
> I want to replace "Welcome <!user-name> to" with "This is", for example.
>  I've spent hours trying to find the right matchChunk() expression given I
> know the first (Welcome) and last word (to) of the chunk but without
> success, I can only get one of them at a time. Thanks in advance for any
> suggestions.
>
> Regards, Andu Novac
> _______________________________________________
> metacard mailing list
> metacard at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/metacard
>




More information about the metacard mailing list