PDA

View Full Version : Resolved Need to replace ; allcharacters



qwikad.com
09-04-2015, 11:48 AM
Need to replace ; allcharacters using:

title = title.replace(//g, '');

1. There's a space after ;
2. By allcharacters I mean A-Z a-z 0-9 _

qwikad.com
09-04-2015, 12:02 PM
Actually after I posted this I tried title = title.replace(/\; .*/, ''); and it seems to be working fine. Is there a better way of doing this? It's tripping all characters (which I am fine with).

dog
09-04-2015, 09:32 PM
I find http://www.regexr.com/ a really useful resource for making sure your regular expressions are doing what you want them to.
I'm not a regEx expert but I'd suggest:


title = title.replace(/\;+./g, ';');

That should replace any character (other than a newline) that follows a semicolon (;) with just a semicolon.

Hope that helps.

qwikad.com
09-06-2015, 01:11 AM
Thank you, really appreciate it!