Irish SEO,  Marketing & Webmaster Discussion

 

Javascript problem

This is a discussion on Javascript problem within the Coding Help forums, part of the Webmaster Help category; Hi all Basically I am trying to create a "word replacer" in javascript I have a string (varying piece of ...


Go Back   Irish SEO, Marketing & Webmaster Discussion > Webmaster Help > Coding Help

Register Forum Rules FAQDonate Members List Calendar Search Today's Posts Mark Forums Read


Notices

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 21-06-2007, 10:53 AM
ph3n0m's Avatar
Webmonkey
Recent Blog: Show and click
 
Join Date: Jan 2006
Location: Ireland
Posts: 300
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
ph3n0m will become famous soon enough
Default Javascript problem

Hi all

Basically I am trying to create a "word replacer" in javascript

I have a string (varying piece of text, X amount of characters long.

I also have a comma seperated array that I have split - my main problem is that I cannot figure out the best way to do a find and replace, matching any of the words in my array to anything in the text string I have.

Anyone have any ideas - or even a working model of what I am looking for?
__________________
Information for Unmarried Parents | blog | bash.org
I gotta gotta get away, get away from the human race
I don't know what I'll see, don't even know what I'll find
I don't know what to pack, never been to a trip at the mind
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 21-06-2007, 03:57 PM
ph3n0m's Avatar
Webmonkey
Recent Blog: Show and click
 
Join Date: Jan 2006
Location: Ireland
Posts: 300
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
ph3n0m will become famous soon enough
Default

Well I got this sorted from through a good friend in Canada

The solution was relatively simple

Code:
<script type="text/javascript">
var longstring = "comma seperate list of words";
var brokenstring = longstring.split(",");
var string = "text to be parsed";
	for (i=0;i<brokenstring.length;i++){
	var newString = string.replace(/brokenstring[i]/gi,"<b>"+brokenstring[i]+"</b>");
	}
	document.write(newString);
</script>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
javascript, problem

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads

Thread Thread Starter Forum Replies Last Post
javascript 7aken Coding Help 1 03-04-2007 03:50 PM
javascript help 7aken Coding Help 2 20-02-2007 06:09 AM
Javascript menu bug? ButtermilkJack Coding Help 1 15-01-2007 03:21 PM
Javascript Captcha for use on forms louie Coding Help 8 23-10-2006 09:22 AM
Javascript Menu Help (again...)? ButtermilkJack Coding Help 18 25-04-2006 12:32 PM


Sponsored links

Paid On Results


All times are GMT +1. The time now is 04:56 AM.


Powered by: vBulletin Version 3.7.3, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
Hosted in Ireland by Blacknight - Test your ISP |Irish Hosting Directory| Armchair.ie|Logo by Eden Web Design|Avatars by Afterglow |Latest Blog Entries | VPS HostingAd Management by RedTyger

Search Engine Friendly URLs by vBSEO 3.2.0