replace plus sign character with EVAL

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
techimac
Posts: 287
Joined: Fri Feb 20, 2015 9:27 pm

replace plus sign character with EVAL

Post by techimac » Fri Sep 14, 2018 12:31 am

I am not able to make EVAL statement to replace + with a blank space

https://www.google.com/maps/place/126+W ... -83.033201

SET mAdd EVAL("var x='{{!URLCURRENT}}';x=x.split('place/')[1].split('/')[0];x.replace(/\+/g, ' ');")
PROMPT {{mAdd}}


replacement part needs a fix

iMacros 8.9.7
Windows 8.1
Firefox 47
Last edited by techimac on Fri Sep 14, 2018 11:28 pm, edited 1 time in total.
techimac
Posts: 287
Joined: Fri Feb 20, 2015 9:27 pm

Re: replace plus charcater with EVAL

Post by techimac » Fri Sep 14, 2018 12:31 am

I know replace can be added after second split
will do once I know correct format of replacement text
techimac
Posts: 287
Joined: Fri Feb 20, 2015 9:27 pm

Re: replace plus charcater with EVAL

Post by techimac » Fri Sep 14, 2018 12:32 am

https://stackoverflow.com/questions/246 ... javascript

still cant make it work inside EVAL
techimac
Posts: 287
Joined: Fri Feb 20, 2015 9:27 pm

Re: replace plus charcater with EVAL

Post by techimac » Fri Sep 14, 2018 12:37 am

SET mAdd EVAL("var x='{{!URLCURRENT}}';x=x.split('place/')[1].split('/')[0];x.replace(/i/g, ' ');")
PROMPT {{mAdd}}


can replace "i" but not "+"
chivracq
Posts: 8217
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: replace plus character with EVAL

Post by chivracq » Fri Sep 14, 2018 1:09 am

techimac wrote:I am not able to make EVAL statement to replace + with a blank space

https://www.google.com/maps/place/126+W ... -83.033201

Code: Select all

SET mAdd EVAL("var x='{{!URLCURRENT}}';x=x.split('place/')[1].split('/')[0];x.replace(/\+/g, '  ');")
PROMPT {{mAdd}}
replacement part needs a fix

iMacros 8.9.7
Windows 8.1
Firefox 47
techimac wrote:I know replace can be added after second split
will do once I know correct format of replacement text
techimac wrote:https://stackoverflow.com/questions/246 ... javascript

still cant make it work inside EVAL
techimac wrote:

Code: Select all

SET mAdd EVAL("var x='{{!URLCURRENT}}';x=x.split('place/')[1].split('/')[0];x.replace(/i/g, ' ');")
PROMPT {{mAdd}}
can replace "i" but not "+"
Hum..., very impressed to see that you can make a bit of "Research" sometimes...! Very good...! :D
Then, OK, I'll answer this one... 8)

2 easier Solutions (than the one(s) on SOF)...:

Code: Select all

VERSION BUILD=8820413 RECORDER=FX
TAB T=1
'https://www.google.com/maps/place/126+Wisconsin+Ave,+Columbus,+OH+43222,+USA/@39.960997,-83.0353897,17z/data=!3m1!4b1!4m5!3m4!1s0x88388f0bcde7eead:0x4861119f539b0dd4!8m2!3d39.960997!4d-83.033201

'SET mAdd EVAL("var x='{{!URLCURRENT}}';x=x.split('place/')[1].split('/')[0];x.replace(/\+/g, ' ');")

SET mAdd EVAL("var u='{{!URLCURRENT}}'; var x,y,z; x=u.split('place/'); y=x[1].split('/'); z=y[0].split('+').join(' '); z;")
PROMPT _{{mAdd}}_
And a bit shorter...:

Code: Select all

VERSION BUILD=8820413 RECORDER=FX
TAB T=1
'https://www.google.com/maps/place/126+Wisconsin+Ave,+Columbus,+OH+43222,+USA/@39.960997,-83.0353897,17z/data=!3m1!4b1!4m5!3m4!1s0x88388f0bcde7eead:0x4861119f539b0dd4!8m2!3d39.960997!4d-83.033201

SET mAdd EVAL("var u='{{!URLCURRENT}}'; var x,y,z; x=u.split('/'); z=x[5].split('+').join(' '); z;")
PROMPT _{{mAdd}}_
Both give the following Result in the 'PROMPT'...: (Underscores as Delimiters...)
_126 Wisconsin Ave, Columbus, OH 43222, USA_
(Tested on iMacros for FF v8.8.2, PM v26.3.3, Win10_x64.)
Last edited by chivracq on Fri Sep 14, 2018 1:34 am, edited 1 time in total.
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
Posts: 8217
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: replace plus character with EVAL

Post by chivracq » Fri Sep 14, 2018 1:16 am

Hum..., and if you prefer your Syntax, you simply need to double escape the '+' Sign...
This one works as well...:

Code: Select all

SET mAdd EVAL("var x='{{!URLCURRENT}}';x=x.split('place/')[1].split('/')[0];x.replace(/\\+/g, ' ');")
PROMPT _{{mAdd}}_
And one more...:

Code: Select all

SET mAdd EVAL("var x='{{!URLCURRENT}}';x=x.split('place/')[1].split('/')[0];x.replace(/[+]/g, ' ');")
PROMPT _{{mAdd}}_
Hum, and could you correct the ugly Typo in your Thread Title...? :roll:
(Nobody is going to search the Forum using "charcater" [sic!] as Keyword...! :roll: )
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
techimac
Posts: 287
Joined: Fri Feb 20, 2015 9:27 pm

Re: replace plus charcater with EVAL

Post by techimac » Fri Sep 14, 2018 1:38 am

I got the data from other HTML TAG in mean time.
techimac
Posts: 287
Joined: Fri Feb 20, 2015 9:27 pm

Re: replace plus charcater with EVAL

Post by techimac » Fri Sep 14, 2018 1:39 am

Code: Select all

TAG POS=1 TYPE=META ATTR=itemprop:description EXTRACT=HTM
SET mAdd EVAL("var x='{{!EXTRACT}}';var pos1=x.indexOf('content=');var pos2=x.indexOf('itemprop',pos1);x.substr(pos1+9,pos2-pos1-11).trim();")
prompt {{mAdd}}
chivracq
Posts: 8217
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: replace plus character with EVAL

Post by chivracq » Fri Sep 14, 2018 2:15 am

techimac wrote:I got the data from other HTML TAG in mean time.
techimac wrote:

Code: Select all

TAG POS=1 TYPE=META ATTR=itemprop:description EXTRACT=HTM
SET mAdd EVAL("var x='{{!EXTRACT}}';var pos1=x.indexOf('content=');var pos2=x.indexOf('itemprop',pos1);x.substr(pos1+9,pos2-pos1-11).trim();")
prompt {{mAdd}}
Foufff..., that's a very cumbersome and unreliable Workaround in my Opinion... And you are "lucky" that "they" didn't make a Typo in all that extra-redundant Meta-Data...
And that's not really/exactly the Answer to your OP...

>>>

Hum, and don't bother at least acknowledging that you've seen my Replies, and confirmed that my (4) Solutions work... Expecting a mini-Thanks is probably too much asking, I reckon... :roll:
And don't bother either correcting the Typo in your Thread Title like I asked you... :roll:

[I was being "nice" to you @techimac in this Thread, I stopped answering your Threads several months ago if you've noticed..., this one was a bit of "a second chance", but hum..., I'm still not very-very "impressed"... Hum, at least you did a bit of Research this time, and you impressively shared your Solution, that's already a big Improvement, ah-ah... But OK, never mind...]
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
techimac
Posts: 287
Joined: Fri Feb 20, 2015 9:27 pm

Re: replace plus charcater with EVAL

Post by techimac » Fri Sep 14, 2018 11:27 pm

Thanks a lot!

I have to do fast so found alternative till help comes.
chivracq
Posts: 8217
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: replace plus character with EVAL

Post by chivracq » Fri Sep 14, 2018 11:44 pm

techimac wrote:Thanks a lot!

I have to do fast so found alternative till help comes.
Hum, Typo in Thread Title corrected... (not in any of all your other Posts, probably part of the "I have to do fast" Methodism, but never mind...), but OK, good enough...

Yeah well, "I have to do fast" is "ADHD Behaviour" and never works and has never worked in any Programming Language...! :roll:
ADHD/Quick Programmers (hum, and Testers a well) are a complete "pain in the ass" in the Programming Industry, => 5x/10x more Time and Energy is/are usually needed to solve their stupid Bugs afterwards than if they had taken a bit the Time to test their Program/Script a bit "correctly"... :roll:
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
Post Reply