Best way to do search and replace

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
mjpg
Posts: 2
Joined: Tue Jan 27, 2009 9:28 am

Best way to do search and replace

Post by mjpg » Tue Jan 27, 2009 9:40 am

I have a lot of CMS pages that have an organisation name to be changed. To do this I'd like to be able to change the text in input boxes and text areas - for example:

Code: Select all

"Information from ABC Company"
to become

Code: Select all

"Information from DEF Organisation"
I can see how to extract the input, and how to write it back, but not how to replace part of the extracted text. iMacros does not seem to have 'REPLACE'.

I assume this is where the scripting interface comes in? I have some scripting experience, but mainly PHP and Javascript.

What is the best/quickest way to do this?

Using iMacros Firefox 3 extension, XP pro.
dharmendra2000
Posts: 214
Joined: Fri Jul 04, 2008 1:28 pm
Location: Ahmedabad
Contact:

Re: Best way to do search and replace

Post by dharmendra2000 » Tue Jan 27, 2009 11:14 am

Question is not 100% clear but looking at below code...
Information from ABC Company
Information from DEF Organisation

I think you want to enter different values in textbox, and underlined value will change every time, is it so?
mjpg
Posts: 2
Joined: Tue Jan 27, 2009 9:28 am

Re: Best way to do search and replace

Post by mjpg » Tue Jan 27, 2009 11:36 am

The text box will have text:
Information from ABC Company

I want to replace "ABC Company" with "DEF Organisation"

so that the text in the text box reads:
Information from DEF Organisation

Can I do this with the Javascript macro files included with iMacro - eg:
1. run a macro to extract the text
2. Use the JS to do the replacement
3. Run a further macro to write back the updated text?

Thanks for your reply
Last edited by mjpg on Tue Jan 27, 2009 3:08 pm, edited 1 time in total.
additional001
Posts: 175
Joined: Sun Jul 06, 2008 3:24 am

Re: Best way to do search and replace

Post by additional001 » Tue Jan 27, 2009 3:03 pm

Yes all of that should be possible with Javascript and iim scripting. If you have more than one Company name you have to replace you may want to use a CSV file to read from and post back with. Otherwise you can just use "A DEF Company" in a variable or straight text.
Post Reply