简体   繁体   中英

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;joelle.dupont@mail.com
Alex;Léger;134234;alex.leger@mail.com

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;\L$1.$2@mail.com\E\n

But it wouldn't replace characters with accents :

Joëlle;Dupont;123456;joëlle.dupont@mail.com
Alex;Léger;134234;alex.léger@mail.com

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

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](?!.*;)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM