javascript - Replace a bracket that matches a criteria -


in following string:

(my name zeeze :) , happy ;)) 

i need replace ) __br__ part of pattern satisfied regex:

[8|:|;|\*]{1}[-c^;\*]?\) 

reference: regex playground

i cannot replace ending ) because not part of pattern.

what way achieve this?

you may in callback method:

var s = "(my name zeeze :) , happy ;))";  console.log(    s.replace(/[8:;*][-c^;*]?\)/g, function($0) {      return $0.replace(/\)/g, "__br__")    })  )  // => (my name zeeze :__br__ , happy ;__br__)

note | inside character class [8|:|;|\*] treated literal | pipe symbol, think human error. {1} redundant atom matched once default. there no need escape * char inside character class, parsed literal asterisk symbol there.


Comments

Popular posts from this blog

javascript - Create a stacked percentage column -

Optimising Firebase database by automatically overwriting data -

javascript - Angular UI-Grid customTemplate directive causing rows to load slowly/? -