Replacing All Characters

Support for iMacros. The iMacros software is the unique solution for automating every activity inside a web browser, for data extraction and web testing.

Moderators: Community Moderators, iMacros Moderators

Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the Google search box (at the top of each forum page) to see if a similar problem or question has already been addressed. This will search the entire contents of the forums as well as the iMacros Wiki.
3. We can respond much faster to your posts if you include the following information:

CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST

Answering your own posts (e.g. attempting to "bump" your topic) drops your topic from the list of unanswered threads, so it may actually receive less views.

Replacing All Characters

by cam on Fri May 26, 2017 8:35 pm

iMacros Version 8.9.7
Firefox 53.0.3
Windows 10

I'm so close to completing what I need but I'm stumped. I'm trying to replace every comma in a string of text with nothing (deleting the commas). And after that, submit the edited string into a form. Below is the code I currently have. It works, but only the first comma is deleted, I need them all to go away.
Code: Select all
VERSION BUILD=8970419 RECORDER=FX

SET !DATASOURCE C:\Users\Luke\Desktop\data.txt

SET !VAR2 {{!COL4}}

SET !VAR2 EVAL("\"{{!VAR2}}\".replace(\",\",\"\");")

TAG POS=1 TYPE=INPUT:TEXT FORM=ID:masthead-search ATTR=ID:masthead-search-term CONTENT={{!VAR2}}
cam
 
Posts: 6
Joined: Wed May 24, 2017 4:47 pm

Re: Replacing All Characters

by iimfun on Fri May 26, 2017 11:11 pm

Okay, let the commas go away
Code: Select all
SET !VAR2 EVAL("\"{{!VAR2}}\".replace(/,/g, \"\");")
iimfun
 
Posts: 239
Joined: Tue Jul 19, 2016 6:06 am

Re: Replacing All Characters

by cam on Sat May 27, 2017 10:09 am

iimfun wrote:Okay, let the commas go away

Worked perfect, thanks so much!
cam
 
Posts: 6
Joined: Wed May 24, 2017 4:47 pm

Re: Replacing All Characters

by chivracq on Sat May 27, 2017 11:08 am

cam wrote:
Code: Select all
iMacros Version 8.9.7
Firefox 53.0.3
Windows 10


I'm so close to completing what I need but I'm stumped. I'm trying to replace every comma in a string of text with nothing (deleting the commas). And after that, submit the edited string into a form. Below is the code I currently have. It works, but only the first comma is deleted, I need them all to go away.
Code: Select all
VERSION BUILD=8970419 RECORDER=FX

SET !DATASOURCE C:\Users\Luke\Desktop\data.txt

SET !VAR2 {{!COL4}}

SET !VAR2 EVAL("\"{{!VAR2}}\".replace(\",\",\"\");")

TAG POS=1 TYPE=INPUT:TEXT FORM=ID:masthead-search ATTR=ID:masthead-search-term CONTENT={{!VAR2}}

iimfun wrote:Okay, let the commas go away
Code: Select all
SET !VAR2 EVAL("\"{{!VAR2}}\".replace(/,/g, \"\");")

And here is another way to do a Global 'replace()' as well which works as well on (most) Special Characters that don't need to be escaped like in 'REGEX' with the 'g' Switch...
Code: Select all
SET !VAR2 EVAL("'{{!VAR2}}'.split(',').join('');")
- (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: 6479
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)


Return to General Support & Discussions

Who is online

Users browsing this forum: No registered users and 8 guests

-->