Tuesday, 13 August 2013

JavaScript Regex: Replace |b| with

JavaScript Regex: Replace |b| with

I've got some funky JSON I'm dealing with, the client is sending it with
these odd html tags, |b| and |\br| all over the place. So I want to
replace them with and
respectively.
I'm trying to run the following str.replace function on the string, but I
can't seem to target the pipe characters correctly.
string.replace(/[|b|]/, '<b>');
I've also tried /|b|/, /\|b\|/
Any help is appreciated

No comments:

Post a Comment