I have to parse (in JS) an e-mail address that originally, instead of a @ has a dot. Obviously I want to show the @ instead of the dot.
var mail = "name.domain.xx"
We have two cases:
name contains some dots itself and they are backslashed:
name\.surname.domain.xx
name contains only regular characters (non dots)
In this topic I found a way to implement the negative lookbehind and this is what I did:
mail = mail.replace(/(\\)?\./, function ($0, $1) { return $1?$0:"@"; });
but it's not working because in case (1) it finds the \., it does not touch it, and of course it stops.
On the other end, if I use the option g, it substitute also the third dot obtaining name.surname@domain@xx
Now, is there a way to say: I want to look in the whole string but I want to stop in the first match? I hope I explained myself.
Cheers