At 8:23 AM -0700 3/11/1999, Leston Drake wrote:
>Could you help explain what the following mean, when used with the
>MatchText function?
I can try, but it's a long time since I put them together. Regex
expressions must be the most unreadable form of writing devised.
Almost as bad as a tax return.
But before doing that, I would suggest looking at Ruediger's
suggested script, which is a lot more elegant and easier to read than
these. I also suspect it's a lot faster, although speed probably
isn't a big issue unless the data in question is very large, or
you're accessing it often. (Ruediger, was there a small mistake in
your script? Should the line <put 1 into state> not read <put true
into groupFound>?)
>1. From matchText(pData,cr & "\[" & pGroup & "\]" & cr & "(.*)",tMatched) :
> a. "\[" & pGroup & "\]"
> b. "(.*)"
Square brackets have a special meaning in regex expressions,
therefore they have to be escaped with a backslash if you are
searching for one.
".*" means any string of characters. In this case it matches all
characters after the cr to the end of the data. The parentheses
denote which part of the matched text should be placed in the
variable tMatched. (See the example in the mc reference under
<matchText> for how to collect a number of pieces of data at one
time.)
>2. From matchText(tMatched, "(" & cr & "\[)", tMatchedx) :
> a. "(" & cr & "\[ )"
You can probably work this out from the above. It matches the text
down to the next section title if there is one, and puts it in
tMatchedx.
>3. From matchText(tGroup,cr & pKey & "=" & "([^" & cr & "]*)", tResult)
> a. "([^" & cr & "]*)"
Pretty, isn't it? In English, the part inside the parenthises means
match any string of characters that doesn't have a carriage return,
so it matches to the end of the line, which is the value we're
looking for.
I'd be interested to hear whether regex is used frequently.
Ruediger's script shows how it may be possible to find better
solutions. Since I wrote these scripts, I don't think I've ever used
it again in Metacard. On the other hand, I use regex (or GREP)
searches a lot in text editing.
<plug for software in need of support>
For Mac users who need some very powerful search functions in a word
processor, try Nisus Writer. It's search functions combined with it's
macro language allow for some very fancy text manipulation. And in
addition to allowing the typing of long and ugly GREP expressions, it
also has a neat way to build expressions without knowing the syntax.
It also has many other nice editing features.
<\plug>
Cheers
Dave Cragg
_____________________________________________
The LACS Centre (Business English Training Resources)
mailto:[EMAIL PROTECTED]
http://www.lacscentre.co.uk
_____________________________________________