Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bulk replacement of strings in single text file (Notepad++)

I am using Notepad++ to edit a text file that has been poorly encoded log. The program didn't take into account the AZERTY keyboard layout of the user. The result is a text file as follows (example I made up)

Hi guysm this is Qqron<
I zonder zhen ze cqn go to the szi;;ing pool together
:y phone nu;ber is !%%)@!#@@#(
Cqll ;e/

I need to make bulk replacement of characters as follows

a > q

q > a

[/0] > 0 

! > 1

and a few others

Is it possible to create a table of characters to be replaced ? I'm a bit of a beginner and I don't know whether Notepad++ allows to run scripts

like image 604
user2666801 Avatar asked Aug 09 '13 05:08

user2666801


People also ask

How do you mass replace words in Notepad?

Open the text file in Notepad. Click Edit on the menu bar, then select Replace in the Edit menu. Once in the Search and Replace window, enter the text you want to find and the text you want to use as a replacement. See our using search and replace and advanced options section for further information and help.

How do you replace an entire line in Notepad++?

Notepad++ is very good at this kind of task. It has a Search and Replace feature which lets you specify a regular expression (also known as "RegEx") for the text to find and its replacement. You can access it from the Search menu or by pressing Ctrl+H.


1 Answers

Notepad++ has a macro recorder, but macros can't be written in any documented embedded language. You could potentially record a macro that does 70 or so search and replace operations. See this explanation. There is some information on "hacking" the macro language here.

Clearly Notepad++ was not meant for this task. The Python solutions are okay, but Perl was meant originally for stuff exactly like this. Here's a one-liner. This is for Windows. In bash/Linux, replace the double quotes with single ones.

perl -n -e "tr/aqAQzwZW;:!@#$%^&*()m\/</qaQAwzWZmM1234567890:?./;print"

It will do what @kreativitea's solution does (I used his translation strings), reading the standard input and printing to standard output.

like image 129
Gene Avatar answered Sep 20 '22 05:09

Gene