SEARCH command and Regular Expression

Discussions and Tech Support specific to the iMacros Firefox add-on.
Forum rules
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
Julianluttrell
Posts: 2
Joined: Sun Jun 24, 2012 9:31 pm

SEARCH command and Regular Expression

Post by Julianluttrell » Sun Jun 24, 2012 9:39 pm

Hi everyone,

Although I have been using iMacros quite successfully for a while now, I have just hit a point where my knowledge of Regular Expressions fails me. I hope it is OK to ask for RegExp help here?

I have a web page tha contains within it the text (the digits are unknown before the fact):

"elementNumber":"12345678"

The double quotes are present in the page source.

I want to extact the characters 12345678 using SEARCH, but cannot work out what Regexp to use. Can anybody provide me with the correct Regexp?

Thanks in advance,

Julian
siniy
Posts: 118
Joined: Sat Nov 07, 2009 7:44 pm

Re: SEARCH command and Regular Expression

Post by siniy » Sun Jun 24, 2012 9:56 pm

Code: Select all

SEARCH SOURCE=REGEXP:"elementNumber":"([0-9]*)" EXTRACT="$1"
PROMPT {{!EXTRACT}}
Use "The Regex Coach" I test all my regexes in it.
http://www.weitz.de/regex-coach/
Julianluttrell
Posts: 2
Joined: Sun Jun 24, 2012 9:31 pm

Re: SEARCH command and Regular Expression

Post by Julianluttrell » Mon Jun 25, 2012 12:21 pm

Thank you, that was perfect. I was 'escaping' too many levels there!! :D
janib4all
Posts: 132
Joined: Wed Jul 21, 2010 6:44 am
Location: Karachi, Sindh, Pakistan
Contact:

Re: SEARCH command and Regular Expression

Post by janib4all » Wed Jun 27, 2012 5:22 pm

I am assuming that !EXTRACT contains this string ("elementNumber":"12345678"). Try following code:

SET !VAR1 EVAL("s = '{{!EXTRACT}}'.match/.elementNumber...{.+}$./; s[1];")
PROMPT {{!VAR1}}

Above code will prompt '12345678' without quotes.
Hire the BoT-fReeak!
botspecialist.blogspot.com
Post Reply