![]() |
Find and replace multiple words with javascript
I am looking for a way to find and replace multiple words within a sentence using javascript. Ideally I would like to take a sentence and replace multiple words within that sentence i.e.
text **WORD 1** text | text **WORD 2** text How can I replace both WORD1 and WORD2 with independent different words? i.e. WORD1= New-word-1 WORD2= New-word-2 here is the code: http://jsfiddle.net/yaaf8/ and to take it one step further I would like to pull new word values from an excel sheet, run a loop with the new words to be replaced and have the output of the new sentences all on one page. Any guidance would be greatly appreciated. |
possibly missing the point here, but...
Code:
var visitorName = "new word 1"; |
This perhaps?
Code:
<div id = "mydiv">Now is the time for all good men to come to the aid of their country.</div>For importing Excel sheet in Javascript see http://www.roseindia.net/javascript/...ile-data.shtml But it would be simpler to use a text file. Or just have the words in a Javascript array (as above). The whole aim of practical politics is to keep the populace alarmed (and hence clamorous to be led to safety)by menacing it with an endless series of hobgoblins, all of them imaginary. - H.L. Mencken 1880-1956, American Editor, Author, Critic, Humorist |
| All times are GMT +1. The time now is 08:15 PM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.