|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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 |
|
#2
|
||||
|
||||
|
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 |
![]() |
| Viewing: Dev Articles Community Forums > Programming > JavaScript Development > Replace space with "+". \s = invalid char. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|