i have
/b(Bobb |Boby |Bob )?momb/g
i would like to know if there is a simple method like this (it is invented js syntax, it is just my idea of “simple” and i am looking for a real way as simple as that):
.replace(/b(Bobb |Boby |Bob )?momb/g, '$1{Bobby }mom');
I know i could do this:
string.replace(/(Bobb |Boby |Bob )?mom/g, function(match, p1) {
return "Bobby";
});
BUT it is too long.
I am looking for an easier method (like the one with invented syntax)