I’m trying to do a regex find replace on a load of links that contain foreign characters such as ä and replacing them with their encoded version %C3%A4.
For example. I would want to replace
<a href=“wähle.html”>Wähle</a>
to
<a href=“w%C3%A4hle.html”>Wähle</a>
Thanks for your reply! I’m using a program called powergrep which can search regex statements and replace with what I want. So in my original example in the replace field I put ‘%C3%A4’, but what regex can I use in the search field to match anything between href=" and " that contains ä?
Hi,
I was just about to download Powergrep to try it out, then I saw it cost 120€. Oops
So, let me understand: You have a folder full of html files and want to use Powergrep to search through all of these files, line for line, and replace any occurrences of foreign characters within a href attribute with their encoded version. I.e. href="wähle.html" would become href="w%C3%A4hle.html".
Is that correct?
I downloaded Powergrep (test version) and I’ve got your answer (I hope).
In Powergrep:
[LIST]
[]With your directory selected, go to the Action tab
[]Select search and replace
[]Set Search type to Regular expression
[]In Search enter: href="(.*?)"
[]In replace enter: href="$1"
[]Set a tick by “Extra processing. Perform a search and replace on the replacement text or collect text”
[]In extra processing search type “ä”
[]In extra processing replace type “%C3%A4”
[*]Rinse and repeat
[/LIST]This works for me, put please use the preview function before altering anything.