Using matchText with PCRE

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
DavidBurleigh
Posts: 19
Joined: Sun Apr 05, 2009 9:27 am

Using matchText with PCRE

Post by DavidBurleigh » Wed May 06, 2009 11:19 pm

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.

SparkOut
Posts: 2852
Joined: Sun Sep 23, 2007 4:58 pm

Post by SparkOut » Thu May 07, 2009 9:42 am

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.

Bernard
Posts: 351
Joined: Sat Apr 08, 2006 10:14 pm
Location: London, England

Post by Bernard » Fri May 08, 2009 7:24 pm

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.

Post Reply

Return to “Talking LiveCode”