[Javascript] Re: Escaping the PLUS SIGN
BEKIM BACAJ
trojani2000 at hotmail.com
Mon Sep 15 19:01:07 CDT 2003
Why don't you try... -This:
***********************************************
var str ="She sells sea shells by the sea"; // original string
var strCut = "shells"; // text to be replaced by the one below
var replStr = "\+"; // text that replaces the one above
// replacing actions
var reg = new RegExp("\\b" + strCut + "\\b", "gi" )
var newstr = str.replace(reg, replStr)
var str ="She sells sea shells by the sea"; // original string
var strCut = "shells"; // text to be replaced by the one below
var replStr = "\+"; // text that replaces the one above
// replacing actions
var reg = new RegExp("\\b" + strCut + "\\b", "gi" )
var newstr = str.replace(reg, replStr)
**************************************************
Chears!
>From: "innerlab.com" Reply-To: "[JavaScript List]" To: "[JavaScript List]"
>Subject: [Javascript] Re: Escaping the PLUS SIGN Date: Sun, 14 Sep 2003
>16:31:37 -0700
>
>----- Original Message ----- From: "Lewis Shadoff"
>
>
> > Use the character encoding for the plus sign: strCut = "+"; >
>http://www.asciitable.com/
>
>
>Hello: I'm afraid it didn't work. But at least it doesn't trigger a
>javascript error. Thanks anyway.
>
>
> > At 12:00 PM 9/14/2003, innerlab.com wrote:
>
> > >I am trying to replace plus signs in a string with another character,
>but > >I am getting a lot of errors. Below is a simple example in which a
>text > >in a string is replaced by another: > > > >var str ="She sells sea
>shells by the sea"; // original string > > > >var strCut = "shells"; //
>text to be replaced by the one below > >var replStr = "food"; // text that
>replaces the one above > > > >// replacing actions > >var reg = new
>RegExp("\\b" + strCut + "\\b", "gi" ) > >var newstr = str.replace(reg,
>replStr) > > > >// output > >document.write(newstr) > > > >The original
>string becomes "She sells sea food by the sea" > > > >Now, how can I make
>the variable strCut be a plus sign?
>
>
>
>_______________________________________________ Javascript mailing list
>Javascript at LaTech.edu https://lists.LaTech.edu/mailman/listinfo/javascript
_________________________________________________________________
STOP MORE SPAM with the new MSN 8 and get 2 months FREE*
http://join.msn.com/?page=features/junkmail
More information about the Javascript
mailing list