Javascript (Not for Web) need to replace all offending characters -


i writing javascript application allows kind of scripting expand own functionality. (esko) not web. have various text strings various undesirable characters need replace. have works except double quote. have:

function f ()   { //remove illegal characters , replace underscore //list of illegal chars var re = /[\*\"\%\'\@\#\$\%\^\&\*\{\}\[\]\(\)[\]]/gi; var str = "santa fe natural tobacco compa"ny inc %#$%^ american spirit"; var newstr = str.replace(re, ""); //remove double underscores var re = /_+/g; var str = newstr; var newstr = str.replace(re, '_'); return (newstr)   } f (); 

the var str changes every order, different. can change var str line read: var str = 'santa fe natural tobacco compa"ny inc %#$%^ american spirit'; (single quotes) , can double quotes replaced, not singles. need both gone. how can accomplish??

my experience js limited, gentle.

thanks

your code eliminates " when run in console, except had escape (\") in definition of str.


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -