Question About SEARCH command

Discussions and Tech Support related to the iMacros Firefox Add-on, including the built-in Javascript scripting interface for playing .js files.
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
User avatar
322126384
Posts: 32
Joined: Sat Jul 23, 2011 1:39 am

Question About SEARCH command

Post by 322126384 » Wed Aug 10, 2011 1:29 am

I was recently using the SEARCH command to search for a number between 1-8 by using this macro:

Code: Select all

SEARCH SOURCE=REGEXP:"([1-8])" EXTRACT=$1
PROMPT {{!EXTRACT}}
And i noticed that when i tried searching on a page that had a multiple digit number on it. The !EXTRACT only showed the first number in the multiple digit number. And the same goes for the "([1-8])" part of the macro, if i set it to ([1-80]), regardless of whether the number is within this range (e.x. 45) the !EXTRACT value always comes out as if the macro said ([1-8]).

Is there anyway to search for multiple digit numbers with the SEARCH command?
-322126384
MattBell7
Posts: 627
Joined: Thu Nov 26, 2009 11:07 am
Location: United Kingdom

Re: Question About SEARCH command

Post by MattBell7 » Wed Aug 10, 2011 8:04 am

yeh, you just need to your regex correct 1-8 doesn't mean a number in the range 1-8 it means a character in the range, so 1-80 just means 1-8 or a 0 what you need is probably ([0-9]{1,2}) This will match anything between 00 and 99.

Regex is a complex beast, but once you know what you're doing its really powerful.
User avatar
322126384
Posts: 32
Joined: Sat Jul 23, 2011 1:39 am

Re: Question About SEARCH command

Post by 322126384 » Wed Aug 10, 2011 6:30 pm

Thanks so much MattBell7. That really helps. But i just have one more question:

Is there anyway that you can narrow down what the SEARCH command searches for in the source. For example if a webpage's source had many numbers between 0-99 and i wanted to search for a specific place where a number between 0-99 would occur would it be possible or would i need to use the TAG command and use POS and TYPE?
-322126384
MattBell7
Posts: 627
Joined: Thu Nov 26, 2009 11:07 am
Location: United Kingdom

Re: Question About SEARCH command

Post by MattBell7 » Thu Aug 11, 2011 9:45 am

I have raised with iOpus to have the POS command added to SEARCH, as you currently can't do it.

The only other option would be to do something like this:

([0-9]{1,2}).*([0-9]{1,2}) EXTRACT=$2

this would match to the second group, instead of the first
User avatar
322126384
Posts: 32
Joined: Sat Jul 23, 2011 1:39 am

Re: Question About SEARCH command

Post by 322126384 » Thu Aug 11, 2011 2:52 pm

Thanks MattBell87, i wish they would add POS and TYPE to the SEARCH command.

I was going to try using IMAGESEARCH because in my case i can also search through image, but then i realized it is not supported by imacros for firefox.
-322126384
MattBell7
Posts: 627
Joined: Thu Nov 26, 2009 11:07 am
Location: United Kingdom

Re: Question About SEARCH command

Post by MattBell7 » Thu Aug 11, 2011 4:22 pm

they can't add type to it, it just doesn't make sense for how regex works, but POS does (i.e. find the 5th matching occurence of this regex). using type is like saying search for this text pattern, but only match it to a specific html element. SEARCH is a page source based command, it has nothing to do with HTML elements.
User avatar
322126384
Posts: 32
Joined: Sat Jul 23, 2011 1:39 am

Re: Question About SEARCH command

Post by 322126384 » Mon Aug 15, 2011 9:25 am

I hope they include POS in the next version of iMacros. it would really help me out. in the mean time, is it possible to incorporate REGEXP or REGEXP type commands into the TAG command. because in my case i can also search the html attributes.

Thanks in Advance
-322126384
Post Reply