faqts : Computers : Programming : Languages : JavaScript : Language Core : Strings

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

Entry

say this variable $worlds has "red hat server" how can I make this change two "red+hat+server"

Apr 18th, 2002 21:26
Nunya Business, paul smith,


This is fairly easy with the replace() method.

worlds = worlds.replace(/\s/g, "+");

where \s is a space, to change one or more spaces in a row with only one 
+ use \s+. g is for matching globaly (all instances).