Not following RegEx recursion in PCRE
Posted: Thu Aug 06, 2015 6:25 am
I have an application I have been working on that uses regular expressions to extract email addresses from my customer's website.
on mouseUp
put text of field "myHTML" into myHTMLvar
put matchText(myHTMLvar,"([\w]+@[\w]{2,}+\.[\w]{2,}(?R)?)",myEMAIL) into myresult
answer myresult
answer myEMAIL
end mouseUp
I get the first email address just fine, but I am not understanding how to get the PCRE to do recursion. PCRE does not accept the /g modifier and after several days of searching for an alternative (like a combination of (?m) and ^ and $, I am at a loss for how to solve this problem via PCRE regex. I know it is possible, but I am just not getting it.
All the PHP examples online use a function called preg_match_all, but that does not appear to be valid in LiveCode.
I assume I may have to use a chunk variant to find where the first match hits and then start the next match from that point, thus writing a recursive function myself, but I am hoping that is not the case.
Any insight is appreciated.
Rick
on mouseUp
put text of field "myHTML" into myHTMLvar
put matchText(myHTMLvar,"([\w]+@[\w]{2,}+\.[\w]{2,}(?R)?)",myEMAIL) into myresult
answer myresult
answer myEMAIL
end mouseUp
I get the first email address just fine, but I am not understanding how to get the PCRE to do recursion. PCRE does not accept the /g modifier and after several days of searching for an alternative (like a combination of (?m) and ^ and $, I am at a loss for how to solve this problem via PCRE regex. I know it is possible, but I am just not getting it.
All the PHP examples online use a function called preg_match_all, but that does not appear to be valid in LiveCode.
I assume I may have to use a chunk variant to find where the first match hits and then start the next match from that point, thus writing a recursive function myself, but I am hoping that is not the case.
Any insight is appreciated.
Rick