I want to remove some text from which I know the starting characters and the 2 ending characters. The text I want to remove is part of a textfile TestEK.txt and the cleaned text should be in a new textfile Out.txt. My regex worked in an online regex tester, but not in my perlfile and I can not find out why.
#!/usr/bin/perl -w # Remove extra text from a PGN or Text-file. # Aufruf: perl remove2.pl TestEK.txt > Out.txt # This is TestEK.txt: # 1. Ka6 ({Of course not} 1. b6 $2 Kb7 $11) 1... Kb8 (1... f4 2. b6 $1 +8) {[%tqu "What is White's next move?","","",g3,"",0,b6,"misses the +win:",0]} 2. g3 $1 13. g6 c3 # This should be the Out.txt # 1. Ka6 ({Of course not} 1. b6 $2 Kb7 $11) 1... Kb8 (1... f4 2. b6 $1 +8) } 2. g3 $1 13. g6 c3 use strict; my $regex =/\{\[%tqu .* ]}/; my $subst = //; while(<>) { my $line = $_; s/$regex/$subst/gi; }
In reply to Substitution don't work by OldChamp
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |