0

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.

RichardBernards
  • 3,146
  • 1
  • 22
  • 30
wocmm
  • 21
  • 2

1 Answers1

1

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

Casimir et Hippolyte
  • 88,009
  • 5
  • 94
  • 125