REGEXP, Can not compile regular expression
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
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
REGEXP, Can not compile regular expression
I have used the http://gskinner.com/RegExr/ to make this WORKING regular expression:
(?<=")http://mysite.com/.*?(?=")
It means Search for " input and exclude it, then search for http://mysite.com/, then search for any chars, ending with " iput, excluding it.This string match links that refer to mysite.com
But iMacros says error while compiling
SEARCH SOURCE=REGEXP:"(?<=")http://mysite.com/.*?(?=")" IGNORE_CASE=YES EXTRACT=$1
Why?
(?<=")http://mysite.com/.*?(?=")
It means Search for " input and exclude it, then search for http://mysite.com/, then search for any chars, ending with " iput, excluding it.This string match links that refer to mysite.com
But iMacros says error while compiling
SEARCH SOURCE=REGEXP:"(?<=")http://mysite.com/.*?(?=")" IGNORE_CASE=YES EXTRACT=$1
Why?
-
- Posts: 3834
- Joined: Mon May 31, 2010 4:59 pm
Re: REGEXP, Can not compile regular expression
Hi Loginbug,
Two observations: 1) Since the entire regular expression needs to be enclosed within quotes in the iMacros command, you need to escape the quote characters which are a part of your expression:
SEARCH SOURCE=REGEXP:"(?<=\")http://mysite.com/.*?(?=\")" IGNORE_CASE=YES EXTRACT=$1
2) iMacros for Firefox doesn't seem to be able to recognize the "lookbehind" syntax: ?<=
iMacros for IE and the iMacros Browser can both handle this syntax. I will log this an issue for the development team to investigate further.
Two observations: 1) Since the entire regular expression needs to be enclosed within quotes in the iMacros command, you need to escape the quote characters which are a part of your expression:
SEARCH SOURCE=REGEXP:"(?<=\")http://mysite.com/.*?(?=\")" IGNORE_CASE=YES EXTRACT=$1
2) iMacros for Firefox doesn't seem to be able to recognize the "lookbehind" syntax: ?<=
iMacros for IE and the iMacros Browser can both handle this syntax. I will log this an issue for the development team to investigate further.
Regards,
Tom, iMacros Support
Tom, iMacros Support
-
- Posts: 3834
- Joined: Mon May 31, 2010 4:59 pm
Re: REGEXP, Can not compile regular expression
Update:
Therefore, the following macro will work in the iMacros commercial editions and iMacros for IE, but not in iMacros for Firefox:Since iMacros for Firefox uses Javascript regexp engine and the engine does not support lookbehind, only lookforward is possible.
Code: Select all
URL GOTO=http://www.iopus.com/imacros/demo/v6/extract.htm
SEARCH SOURCE=REGEXP:"(?<=Can)(adian)" IGNORE_CASE=YES EXTRACT=$1
PROMPT {{!EXTRACT}}
Regards,
Tom, iMacros Support
Tom, iMacros Support
Re: REGEXP, Can not compile regular expression
I can't change to JavaScript (iMacros 7.2.1.0, Win7 x64, Firefox 4, demo: ok)
This is working
after change.. doesn't:
This is working
Code: Select all
SEARCH SOURCE=REGEXP:\"resourceTickerMetal = {\\W+available: (\\d+)\" EXTRACT=$1
Code: Select all
var macro;
macro = "CODE:";
macro += "SEARCH SOURCE=REGEXP:\"resourceTickerMetal = {\\W+available: (\\d+)\" EXTRACT=$1" + "\n";
iimPlay(macro);
------------------------------ or ------------------------------
iimPlay("CODE: SEARCH SOURCE=REGEXP:\"resourceTickerMetal = {\\W+available: (\\d+)\" EXTRACT=$1");
var extract1 = iimGetLastExtract();
------------------------------ or ------------------------------
iimPlay("CODE: SEARCH SOURCE=REGEXP:\\\"resourceTickerMetal = {\\\\W+available: (\\\\d+)\\\" EXTRACT=$1");
var extract1 = iimGetLastExtract();
Please helpSyntaxError?: wrong format of SEARCH command, line: 1 (Error code: -910)
-
- Posts: 3834
- Joined: Mon May 31, 2010 4:59 pm
Re: REGEXP, Can not compile regular expression
oobe,
You need to escape the backslash characters in your Javascript strings.
You need to escape the backslash characters in your Javascript strings.
Regards,
Tom, iMacros Support
Tom, iMacros Support
Re: REGEXP, Can not compile regular expression
http://www.samplein.com/company/1314096 ... dx%3A1-1-1
here i extract above URL using !CURRENTURL Tag.
i need help to exact company id i.e 1314096
help me as soon as possible ...
help with EVAL or SEARCH with REGEXP Tags...
here i extract above URL using !CURRENTURL Tag.
i need help to exact company id i.e 1314096
help me as soon as possible ...
help with EVAL or SEARCH with REGEXP Tags...
Re: REGEXP, Can not compile regular expression
No need to ask your Question twice..., I reply in your dedicated Thread...prabacse wrote:http://www.samplein.com/company/1314096 ... dx%3A1-1-1
here i extract above URL using !CURRENTURL Tag.
i need help to exact company id i.e 1314096
help me as soon as possible ...
help with EVAL or SEARCH with REGEXP Tags...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Re: REGEXP, Can not compile regular expression
I have a similar problem but i didn't understand the Tech support's answer
This imacros code works:
I want to adapt it in a javascript and play it with the plugin of imacros in firefox.
I tried few times but it didn't work because of the " " of the REGEXP.
Here my javascript code:
Here the error:
Could you help me ?
This imacros code works:
Code: Select all
SEARCH SOURCE=REGEXP:"De ([0-9]{1} [0-9]{3} [0-9]{3} €)" IGNORE_CASE=YES EXTRACT=$1
I tried few times but it didn't work because of the " " of the REGEXP.
Here my javascript code:
Code: Select all
extract ="SEARCH SOURCE=REGEXP:"De ([0-9]{3} [0-9]{3} €)" IGNORE_CASE=YES EXTRACT=$1"+ "\n";
I tried without the " " but i have an other error...SyntaxError: missing ; before statement, line 20 (Error code: -991)
Could you help me ?
Re: REGEXP, Can not compile regular expression
CIM...!BlueOne wrote:I have a similar problem but i didn't understand the Tech support's answer
This imacros code works:I want to adapt it in a javascript and play it with the plugin of imacros in firefox.Code: Select all
SEARCH SOURCE=REGEXP:"De ([0-9]{1} [0-9]{3} [0-9]{3} €)" IGNORE_CASE=YES EXTRACT=$1
I tried few times but it didn't work because of the " " of the REGEXP.
Here my javascript code:Here the error:Code: Select all
extract ="SEARCH SOURCE=REGEXP:"De ([0-9]{3} [0-9]{3} €)" IGNORE_CASE=YES EXTRACT=$1"+ "\n";
I tried without the " " but i have an other error...SyntaxError: missing ; before statement, line 20 (Error code: -991)
Could you help me ?
=> iMacros for FF v8.9.4...?, FF42...?, OS...?
When converting an .iim Statement to a in a .js Script on the fly created Macro, you need to escape Special Characters and Double Quotes so I think here you need to escape the inner Double Quotes (or replace them with Single Quotes):
Code: Select all
extract ="SEARCH SOURCE=REGEXP:\"De ([0-9]{3} [0-9]{3} €)\" IGNORE_CASE=YES EXTRACT=$1"+ "\n";
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Re: REGEXP, Can not compile regular expression
Hello chivracq,
Thank you for your answer.
I add / before and after the REGEX and it works !
Thank you very much for your help.
For information my CIM is Imacros for Firefox 8.9.4 on Mac OS
Thank you for your answer.
I add / before and after the REGEX and it works !
Thank you very much for your help.
For information my CIM is Imacros for Firefox 8.9.4 on Mac OS
Last edited by BlueOne on Mon Nov 30, 2015 7:41 pm, edited 1 time in total.
Re: REGEXP, Can not compile regular expression
Oh...!, so you mean like this:BlueOne wrote:Hello chivracq,
Thank you for your answer.
I add / before and after the REGEX and it works !
Thank you very much for your help.
But be careful the / have to be before the " at the beginning of the REGEX and after the " at the end of the REGEX.
I hope it's gonna help someone else.
For information my CIM is Imacros for Firefox 8.9.4 on Mac OS
Code: Select all
extract ="SEARCH SOURCE=REGEXP:/"De ([0-9]{3} [0-9]{3} €)"/ IGNORE_CASE=YES EXTRACT=$1"+ "\n";
You didn't try with Single Quotes btw, either for the inner Quotes or for the outer Quotes...?
(I don't use 'REGEXP', I don't use .js Scripts, I don't use on the fly created Macros in .js Scripts, I don't have a Mac, so I cannot really do any Testing, ah-ah...! )
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Re: REGEXP, Can not compile regular expression
Hi chivracq,
I update my post because your first solution was correct.
I was too tired when i write my previous post...
By the way i have a similar problem with a EVAL line maybe you could see what's the problem.
I want to transform this imacros code in javascript: (it's work)
After few tries i write this javascript adaptation but still it's doesn't work... any idea ?
I'm sure is the same kind of problem...
Thanks
I update my post because your first solution was correct.
I was too tired when i write my previous post...
By the way i have a similar problem with a EVAL line maybe you could see what's the problem.
I want to transform this imacros code in javascript: (it's work)
Code: Select all
SET !VAR1 EVAL("var a=\"{{!EXTRACT}}\";a.replace(\" \",\"\");")
Code: Select all
extract +="SET !VAR1 EVAL(\"var a='{{!EXTRACT}}';a.replace(( ),())\")"+ "\n";
Thanks
Re: REGEXP, Can not compile regular expression
Well, I'm not sure about my "first solution was correct", because I used Backslashes en even after your EDIT, you left a Forward Slash, so do you have to use Forward or Backward Slashes to escape Double Quotes...!?BlueOne wrote:Hi chivracq,
I update my post because your first solution was correct.
I was too tired when i write my previous post...
Maybe easier if you post yourself your Working Solution...
And you still don't react about Single Quotes either for the inner or for the outer Double Quotes...
For this one, this is very cumbersome, 'EVAL()' is a way to use JavaScript in pure .iim Scripts, you are already in a JavaScript "Environment" because you are creating an .iim Script on the fly in a .js Script (which I already find cumbersome, some "clever" Kid created such a Script years ago and posted it on some obscure Forum to impress other Script Kiddies and that Script has since gone Viral while hardly anybody understands how it works and they all come to the Forum with a Pb though I don't even use (and never have) those stupid Scripts), so you are now embedding JavaScript in an .iim Script embedded in JavaScript.BlueOne wrote:By the way i have a similar problem with a EVAL line maybe you could see what's the problem.
I want to transform this imacros code in javascript: (it's work)
After few tries i write this javascript adaptation but still it's doesn't work... any idea ?Code: Select all
SET !VAR1 EVAL("var a=\"{{!EXTRACT}}\";a.replace(\" \",\"\");")
I'm sure is the same kind of problem...Code: Select all
extract +="SET !VAR1 EVAL(\"var a='{{!EXTRACT}}';a.replace(( ),())\")"+ "\n";
Thanks
So either you use pure .iim Scripts like I do, if you need some Conditional Behaviour, well then OK..., it's OK to use a .js Script (even if I still stick to pure .iim and I do more complex things in pure .iim than I've ever seen in .js Scripts on the Forum...), but then you put the .iim part in an .iim Macro that you call with 'iimPlay()', especially if you still want to use some JavaScript in that .iim. Or you do the JavaScript part directly in your .js Script. Embed x3 is cruising for Trouble=Spanking...!
But for your thing, pfff, dunno, try stg like this:
Code: Select all
extract +='SET !VAR1 EVAL("var a='{{!EXTRACT}}'; a.replace(' ','');")' + "\n";
Code: Select all
extract +="SET !VAR1 EVAL(\"var a=\\\"{{!EXTRACT}}\\\"; a.replace(\\\" \\\",\\\"\\\");\")"+ "\n";
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Re: REGEXP, Can not compile regular expression
To clarify the situation
I wanted to adapt this imacros (.iim) for javascript (.js):
I simply had to replace " of the REGEX by \"
So i finally succeed with this code:
I use Imacros for Firefox 8.9.4 on Mac OS
I wanted to adapt this imacros (.iim) for javascript (.js):
Code: Select all
SEARCH SOURCE=REGEXP:"De ([0-9]{1} [0-9]{3} [0-9]{3} €)" IGNORE_CASE=YES EXTRACT=$1
So i finally succeed with this code:
Code: Select all
extract ="SEARCH SOURCE=REGEXP:\"De ([0-9]{1} [0-9]{3} [0-9]{3} €)\" IGNORE_CASE=YES EXTRACT=$1"+ "\n";
Re: REGEXP, Can not compile regular expression
I am aware that this is not the most optimal thing to do ...For this one, this is very cumbersome, 'EVAL()' is a way to use JavaScript in pure .iim Scripts, you are already in a JavaScript "Environment" because you are creating an .iim Script on the fly in a .js Script (which I already find cumbersome, some "clever" Kid created such a Script years ago and posted it on some obscure Forum to impress other Script Kiddies and that Script has since gone Viral while hardly anybody understands how it works and they all come to the Forum with a Pb though I don't even use (and never have) those stupid Scripts), so you are now embedding JavaScript in an .iim Script embedded in JavaScript.
So either you use pure .iim Scripts like I do, if you need some Conditional Behaviour, well then OK..., it's OK to use a .js Script (even if I still stick to pure .iim and I do more complex things in pure .iim than I've ever seen in .js Scripts on the Forum...), but then you put the .iim part in an .iim Macro that you call with 'iimPlay()', especially if you still want to use some JavaScript in that .iim. Or you do the JavaScript part directly in your .js Script. Embed x3 is cruising for Trouble=Spanking...!
But for your thing, pfff, dunno, try stg like this:
CODE: SELECT ALL
extract +='SET !VAR1 EVAL("var a='{{!EXTRACT}}'; a.replace(' ','');")' + "\n";
or:
CODE: SELECT ALL
extract +="SET !VAR1 EVAL(\"var a=\\\"{{!EXTRACT}}\\\"; a.replace(\\\" \\\",\\\"\\\");\")"+ "\n";
And you may need to use Forward Slashes instead of Backslashes on MacOS, it's still not clear to me..., see my Comment to the first Quote...
And thank you to share your experience with me.
Your second proposition works !!
Code: Select all
extract +="SET !VAR1 EVAL(\"var a=\\\"{{!EXTRACT}}\\\"; a.replace(\\\" \\\",\\\"\\\");\")"+ "\n";