Page 1 of 1

Using matchText with PCRE

Posted: Wed May 06, 2009 11:19 pm
by DavidBurleigh
hi, here's a code snippet:

repeat for each line thisLine in field ParsingCurrent.HTMLText.Field
if matchText(thisLine,"(?Usi)(/\w+@[a-z_]+\.[a-z]{2,})",matchedEmail) then put matchedEmail after matchedList
end repeat

I have tried this several different ways. I even used only "(?Usi)href" as the regex and it wouldn't put anything into matchedList.

If I use:

if matchText(thisLine,"(?Usi)href", matchedEmail) then answer matchedEmail

it works.

The bottom line is, I can't get the PCRE expression up above to match any emails in the list I'm reading, and then I can't get anything that does match to create a new list in the matchedList variable.

Posted: Thu May 07, 2009 9:42 am
by SparkOut
My first thought was that the repeat for each was putting the plain text of the field into "thisLine" each time, and so your sample for checking would not include the actual code, only the visible text.
I was going to suggest trying

Code: Select all

repeat for each line thisLine in the htmlText of field "ParsingCurrent.HTMLText.Field 
"
but on closer look, it seems your test with "answer matchedEmail" is working, so I'm not sure what the issue is.

Posted: Fri May 08, 2009 7:24 pm
by Bernard
try initialising matchedEmail before doing the matchtext e.g.

put empty into matchedEmail

The Dictionary says the variables used by matchText need to be "existing variables".

It might sound dumb, and if it turns out to be the action you need, then your working one liner:

if matchText(thisLine,"(?Usi)href", matchedEmail) then answer matchedEmail

should not be working either.