1

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.

1 Answer 1

2

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](?!.*;)
Sign up to request clarification or add additional context in comments.

7 Comments

They are French letters, and there are also others letters like ç, à, ô… to replace them by c, a, o… respectively. But most importantly, the thing I want to do is for example replace é by e, but only in the mail adress, without modifying the rest of the line.
@Minizarbi Added for the other letters and replace each with the 'main' letter. The regex only modifies the last 'column' in your data if ; is the delimiter. If you have more than one column of email addresses, then you might use (?=[^;@]*@) instead of (?!.*;).
I didn't know the (?!…) or (?=…) and I think it's the solution to my problem, so it works. And I didn't know the two websites you linked.
@Minizarbi If you want me to explain how these work, let me know :) They are called 'lookarounds' in general, and more specifically, (?= ... ) is a positive lookahead and (?! ... ) is a negative lookahead. You can also search those terms on the internet, that's where I learned those in the first place :)
I didn't understand in the first place so I looked here : perldoc.perl.org/perlre.html#Look-Around-Assertions and now I understand, so thank you :)
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.