JavaScript Regex: Replace |b| with <b> -
i've got funky json i'm dealing with, client sending these odd html tags, |b| , |\br| on place. want replace them ,
respectively.
i'm trying run following str.replace function on string, can't seem target pipe characters correctly.
string.replace(/[|b|]/, '<b>');
i've tried /|b|/, /\|b\|/
any appreciated
in regex, [] means "one of these characters", /[|b|]/ means | or b.
you want /\|b\|/g. without g, replaces once.
Comments
Post a Comment