wocmm
wocmm

Reputation: 21

Notepad++ Replacing multiple text and texts in all rows with multiple texts

I have a big txt file. See example below;

||0011||
||0011||
||0011||
||0011||
||0011||
||0011||
||0011||
||0011||
||0011||
||0122||
||0122||
||0122||
||0122||
||0122||
||0122||
||0122||
||0122||
||0122||
||0122||
||0232||
||0232||
||0232||
||0232||
||0232||
||0232||
||0232||
||0232||
||0232||
||0232||
||0232||

What i want to do is, i want to replace 0011 with 001112, 0122 with 012234, 0232 with 023213. My problem is, that i want to replace them in one go. I am aware of replacing them in three steps i.e, first i can replace all rows that have 0011 with 001112, similar second time i can replace rows that have 0122 with 012234 etc. Please keep in mind that there are more columns and rows in the file. Above is just an example.

Upvotes: 0

Views: 63

Answers (1)

Casimir et Hippolyte
Casimir et Hippolyte

Reputation: 89584

Since you can't do a conditional replacement with notepad++, you can use this way:

1) add these three lines at the end of your file:

#001112
#012234
#023213

2) use this pattern and replacement:

pattern: \|\|\K(\d+)(?=\|\|[\s\S]+#\1(\d+))|(?:\r?\n#.*)+$
replace: $1$2 

demo

Upvotes: 1

Related Questions