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.
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
Post Reply
cam
Posts: 6
Joined: Wed May 24, 2017 11:47 pm

Replacing All Characters

Post by cam » Sat May 27, 2017 3:35 am

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
Posts: 239
Joined: Tue Jul 19, 2016 1:06 pm

Re: Replacing All Characters

Post by iimfun » Sat May 27, 2017 6:11 am

Okay, let the commas go away

Code: Select all

SET !VAR2 EVAL("\"{{!VAR2}}\".replace(/,/g, \"\");")
cam
Posts: 6
Joined: Wed May 24, 2017 11:47 pm

Re: Replacing All Characters

Post by cam » Sat May 27, 2017 5:09 pm

iimfun wrote:Okay, let the commas go away
Worked perfect, thanks so much!
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Replacing All Characters

Post by chivracq » Sat May 27, 2017 6:08 pm

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)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...
Post Reply