Help with undefined error, Eval & Regex

Discussions and Tech Support related to website data extraction, screen scraping and data mining using iMacros.
Forum rules
iMacros EOL - Attention!

The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.

Thank you again for your business and support.

Sincerely,
The Progress Team

Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
green.pine
Posts: 62
Joined: Thu Nov 04, 2010 5:21 pm

Help with undefined error, Eval & Regex

Post by green.pine » Mon Oct 16, 2017 10:37 pm

Imacros v8.9.7 on FF ver 55.0.3 32-bit, Win 7 32
Hello;
I use EVAL function and Regex to extract emails, I get undefined error
what am I doning wrong here?
I have tested the Regex code in a regex tester site, and it was OK.

Code: Select all

TAG POS=1 TYPE=TEXTAREA ATTR=ID:txt_Dw EXTRACT=HTM
SET !VAR1 EVAL("'{{!EXTRACT}}'.'.match([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6});")                      
PROMPT {{!VAR1}}
I have tried another regex code for the EVAL function for the same purpose from the following thread, but it only returns one email. :(
http://forum.imacros.net/viewtopic.php? ... 023#p64023

Appreciate your help,
Thanks
iimfun
Posts: 239
Joined: Tue Jul 19, 2016 1:06 pm

Re: Help with undefined error, Eval & Regex

Post by iimfun » Tue Oct 17, 2017 6:29 am

green.pine wrote:... but it only returns one email. :(
Until you remove the first index '[0]'

Code: Select all

TAG POS=1 TYPE=TEXTAREA ATTR=ID:txt_Dw EXTRACT=HTM
SET !VAR1 EVAL("'{{!EXTRACT}}'.match(/(([^<>()[\\]\\\.,;:\\s@\\\"]+(\\.[^<>()[\\]\\\.,;:\\s@\\\"]+)*)|(\\\".+\\\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))/g);")
PROMPT {{!VAR1}}
Btw, this solution should also work

Code: Select all

SET !VAR1 EVAL("'{{!EXTRACT}}'.match(/([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})/g);")
and it's simpler!
green.pine
Posts: 62
Joined: Thu Nov 04, 2010 5:21 pm

Re: Help with undefined error, Eval & Regex

Post by green.pine » Tue Oct 17, 2017 2:51 pm

Thank you very much,
now it is working,
Post Reply