The following code works with with a test-inputfile, but not with the real inputfile
# Aufruf: perl removeEK1.pl TestEK.txt > Out.txt
use strict;
use warnings;
my $regex = '\{\[%tqu.*]}';
my $subst = '';
while(<>)
{
my $line =$_;
$line =~ s/$regex/$subst/gi;
print $line;
}
That worked fine with the following file TestEK.txt:
[Event "?"]
[Site "?"]
[Date "1985.??.??"]
[Round "?"]
[White "Neuenschwander, Beat"]
[Black "?"]
[Result "1-0"]
[Annotator "Solution"]
[SetUp "1"]
[FEN "8/5ppk/8/3p2KP/3P2P1/8/8/8 w - - 0 1"]
[PlyCount "17"]
[Source "ChessCafe/CB"]
[SourceDate "2003.10.29"]
BlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBla
1. Ka6 ({Of course not} 1. b6 $2 Kb7 $11) 1... Kb8 (1... f4 2. b6 $18)
+ {[%tqu "What is White's next move?","","",g3,"",0,b6,"misses the wi
+n:",0]} 2. g3 $1 13. g6 c3
BlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBla
1. Ka6 ({Of course not} 1. b6 $2 Kb7 $11) 1... Kb8 (1... f4 2. b6 $18)
+ {[%tqu "What is White's next move?","","",g3,"",0,b6,"misses the wi
+n:",0]} 2. g3 $1 13. g6 c31. Ka6 ({Of course not} 1. b6 $2 Kb7 $11) 1
+... Kb8 (1... f4 2. b6 $18) {[%tqu "What is White's next move?","","
+",g3,"",0,b6,"misses the win:",0]} 2. g3 $1 13. g6 c31. Ka6 ({Of cour
+se not} 1. b6 $2 Kb7 $11) 1... Kb8 (1... f4 2. b6 $18) {[%tqu "What i
+s White's next move?","","",g3,"",0,b6,"misses the win:",0]} 2. g3 $
+1 13. g6 c3
1. Ka6 ({Of course not} 1. b6 $2 Kb7 $11) 1... Kb8 (1... f4 2. b6 $18)
+ {[%tqu "What is White's next move?","","",g3,"",0,b6,"misses the wi
+n:",0]} 2. g3 $1 13. g6 c3
BlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBla
BlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBla
BlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaB
+laBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBla
I got the output I wanted, but when I tested it with a part of my real inputfile, it failed.
.......
[Event "?"]
[Site "?"]
[Date "1933.??.??"]
[Round "?"]
[White "Grigoriev, Nikolay"]
[Black "?"]
[Result "*"]
[Annotator "Solution"]
[SetUp "1"]
[FEN "k7/2p5/8/KP3p2/8/8/6P1/8 w - - 0 1"]
[PlyCount "13"]
[Source "ChessCafe/CB"]
[SourceDate "2003.10.29"]
1. Ka6 ({Of
course not} 1. b6 $2 Kb7 $11) 1... Kb8 (1... f4 2. b6 $18) {[%tqu "Wha
+t is
White's next move?","","",g3,"",0,b6,"misses the win:",0]} 2. g3 $1 ({
+The hasty
} 2. b6 $2 {misses the win:} Kc8 $1 {with the idea 3...cxb6.} 3. b7+ K
+b8 4. g3
c5 5. Kb5 Kxb7 6. Kxc5 Kc7 7. Kd5 f4 $1 8. gxf4 Kd7 $11 {Black saves t
+he game
by seizing the opposition.}) 2... Ka8 ({Another defensive method also
+does not
help} 2... Kc8 3. Ka7 Kd8 4. Kb8 $1 {(an opposition!)} Kd7 5. Kb7 Kd8
+(5... Kd6
6. Kc8 $18) 6. Kc6 {(an outflanking!)} Kc8 7. Kd5 Kb7 8. Ke5 Kb6 9. Kx
+f5 Kxb5
10. g4 c5 11. g5 c4 12. Ke4 $1 {(we shall see this method - an enticem
+ent of
the hostile king under a check - more than once in this book)} Kb4 13.
+ g6 c3
14. Kd3 $1 Kb3 15. g7 c2 16. g8=Q+) {[%tqu "What is White's next move?
+","","",
b6,"",0]} 3. b6 Kb8 {
} 4. Kb5 $1 (4. b7 $2 c5 5. Kb5 Kxb7 $11) 4... Kb7 5. bxc7 Kxc7 {[%tqu
+ "What is White's next move?",
"","",Kc5,"",0]} 6. Kc5 Kd7 {[%tqu "What is White's next move?","","",
+Kd5,
"This time White has seized the opposition, therefore the pawn sacrifi
+ce 7...
f4 is senseless.",0]} 7. Kd5 $18 {This time White has seized the oppos
+ition,
therefore the pawn sacrifice 7...f4 is senseless.} *
[Event "?"]
[Site "?"]
.......
My outputfile now was the same as the inputfile, the searchtext was obviously not found and therefor not removed!!
I'm not able to spot what is going wrong. Pherhaps anyone has an idea?
Help would be very much apreciated!