SunQuest
 
           JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old December 7th, 2004, 09:28 AM
TRXuk TRXuk is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 2 TRXuk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Replace space with "+". \s = invalid char.

Hi, I'm trying to replace all the instances of " " with a "+" using regular expression.

checking out on various site the expresion for a space is "\s". So I type in confidently.

-----------------------------------------------------
<script language="javascript">
str = "hello me";

reg = (\s)
str.replace(reg,' ')

alert(str);
</script>
-----------------------------------------------------

and get "invalid character "\". Anyone know about these regular expressions out there?

Cheers

Sandy

Reply With Quote
  #2  
Old August 8th, 2005, 09:51 AM
Mittineague's Avatar
Mittineague Mittineague is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jul 2005
Location: West Springfield, Massachusetts
Posts: 542 Mittineague User rank is Private First Class (20 - 50 Reputation Level)Mittineague User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 1 Day 2 h 58 m 28 sec
Reputation Power: 3
regex in javscript

Regular expressions are not delimited with parentheses. Try
reg = /\s+/;
str.replace(reg,'+')
the + in the regex indicates 1 or more occurences of a white-space character:
including /r /n /t and /f

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > Replace space with "+". \s = invalid char.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway