1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Replacing Characters in iMacros

Discussion in 'General Scripting Chat' started by lryan22, May 27, 2017.

  1. lryan22

    lryan22 Newbie

    Joined:
    May 27, 2017
    Messages:
    19
    Likes Received:
    1
    Gender:
    Male
    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:
    VERSION BUILD=844 RECORDER=CR
    
    SET !DATASOURCE C:\Users\Ryan\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}}
     
  2. lryan22

    lryan22 Newbie

    Joined:
    May 27, 2017
    Messages:
    19
    Likes Received:
    1
    Gender:
    Male
    Someone helped me on the imacros forum :) Here is the solution:
    Change line 7 to:
    Code:
    SET !VAR2 EVAL("\"{{!VAR2}}\".replace(/,/g, \"\");")