Jump to content
UBot Underground

Regex Find Only First Email Address


Recommended Posts

Hey guys

 

regex always does my head in, can someone please help

 

I want to scrape whois data from: whois.ausregistry.com.au/whois/whois_local.jsp

 

I want to regex find only the first email address occurrence

 

this regex works in Regex builder but not in the bot: ^[^.!?]*[\w\-][\w\-\.]+@[\w\-][\w\-\.]+[a-zA-Z]{1,4}

 

I also want to match the second email address occurrence but I have not got past the first..lol

 

Thanks

set(#rmail,$find regular expression($scrape attribute(<tagname="html">,"innerhtml"),"^[^.!?]*[\\w\\-][\\w\\-\\.]+@[\\w\\-][\\w\\-\\.]+[a-zA-Z]\{1,4\}"),"Global")

Link to post
Share on other sites

Thanks for the help, i got the result i wanted

 

but It seems like the incorrect way of doing things, but either way i got a result

 

I'm not even going to try and regex the second email address

 

SOLVED

 

I first set a regex to find and scrape the page to get both emails from the page

set(#rmail,$find regular expression($scrape attribute(<tagname="html">,"innerhtml"),"[\\w\\-][\\w\\-\\.]+@[\\w\\-][\\w\\-\\.]+[a-zA-Z]\{1,4\}"),"Global")

I then set a regex to find and scrape just the first result from the first set's results

set(#firstEmail,$list item($find regular expression(#rmail,"^[^.!?]*([\\w\\-][\\w\\-\\.]+@[\\w\\-][\\w\\-\\.]+[a-zA-Z]\{1,4\})"),0),"Global")
Link to post
Share on other sites
  • 9 months later...

Do it like this

 

set(#firstEmail,$list item($find regular expression($document text,"^[^.!?]*[\\w\\-][\\w\\-\\.]+@[\\w\\-][\\w\\-\\.]+[a-zA-Z]\{1,4\}"),0),"Global")

 

 

This is very smart, It has helped me out also with another piece of regex where I only wanted the first instance

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...