Alexandre Lagane
Alexandre Lagane

Reputation: 69

Replace inside matched string with Notepad++ and regex

I have some lines in a text file :

Joëlle;Dupont;123456
Alex;Léger;134234

And I want to replace them by :

Joëlle;Dupont;123456;[email protected]
Alex;Léger;134234;[email protected]

I want to replace all characters with accents (é, ë…) by characters without accents (e, e…) but only on the mail adress, only on a part of the line.

I know I can use \L\E to change uppercase letter into lowercase letter but it's not the only thing I have to do.

I used :

(.*?);(.*?);(\d*?)\n

To replace it by :

$1;$2;$3;\[email protected]\E\n

But it wouldn't replace characters with accents :

Joëlle;Dupont;123456;joë[email protected]
Alex;Léger;134234;alex.lé[email protected]

If you have any idea how I could do this with Notepad++, even with more than one replacement, maybe you can help me.

Upvotes: 1

Views: 671

Answers (1)

Jerry
Jerry

Reputation: 71538

I don't know your whole population, but you could use the below to replace the variations of e with an e:

[\xE8-\xEB](?!.*;)

And replace with e.

[I got the range above from this webpage, taking the column names]

regex101 demo

This regex matches any è, é, ê or ë and replaces them with an e, if there is no ; on the same line after it.


For variations of o:

[\xF2-\xF6](?!.*;)

For c (there's only one, so you can also put in ç directly):

\xE7(?!.*;)

For a:

[\xE0-\xE5](?!.*;)

Upvotes: 2

Related Questions