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

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -