dimanche 28 juin 2015

Using replace() replaces too much content

I'm using replace() to transform t in gwhen tis not followed by a letter p, I'm using this line of code:

"tpto".replace(/(t)[^p]/g, "g");

However, the result of this function is tpgand I was expecting tpgo. As I don't know which letter will follow the t I need something dynamic but I don't know what to do, any ideas?

Aucun commentaire:

Enregistrer un commentaire