Home › Forums › JavaScript › Character replace using jquery › Reply To: Character replace using jquery
December 14, 2013 at 6:06 pm
#158362
Participant
It’s late and I’m sleepy so not sure if this is the best solution, but this RegEx should work /([^:]\/)\//g
, use it like:
s = s.replace(/([^:]\/)\//g, '$1');
Basically it replaces every //
with /
as long as it’s not preceded by a colon (like in http://
).
Not jQuery, but I don’t think jQuery got any helper functions for this anyway. Curious about use cases though.