Help with undefined error, Eval & Regex

Discussions and Tech Support related to website data extraction, screen scraping and data mining using iMacros.

Moderators: Community Moderators, iMacros Moderators

Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the Google search box (at the top of each forum page) to see if a similar problem or question has already been addressed. This will search the entire contents of the forums as well as the iMacros Wiki.
3. We can respond much faster to your posts if you include the following information:

CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST

Answering your own posts (e.g. attempting to "bump" your topic) drops your topic from the list of unanswered threads, so it may actually receive less views.

Help with undefined error, Eval & Regex

by green.pine on Mon Oct 16, 2017 3: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?f=7&t=24571&p=64023#p64023

Appreciate your help,
Thanks
green.pine
 
Posts: 62
Joined: Thu Nov 04, 2010 10:21 am

Re: Help with undefined error, Eval & Regex

by iimfun on Mon Oct 16, 2017 11:29 pm

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!
iimfun
 
Posts: 238
Joined: Tue Jul 19, 2016 6:06 am

Re: Help with undefined error, Eval & Regex

by green.pine on Tue Oct 17, 2017 7:51 am

Thank you very much,
now it is working,
green.pine
 
Posts: 62
Joined: Thu Nov 04, 2010 10:21 am


Return to Data Extraction and Web Screen Scraping

Who is online

Users browsing this forum: Bing [Bot] and 3 guests

-->