Thank You for your help and patience and replying again. I have to excuse for my formal mistakes in the update, I should have read "How do I change ..." before. I have changed / replaced my script with your solution and I have created a small testfile
This is my script now:
my $t = do { local $/; <>; }; my $pre = qr{ \S+ \s }xms; my $post = qr{ \s [^\n]+ \n [^\{]+ \{ }xms; ;; $t =~ s{ ^ $pre b $post \K Weiss \b} {Schwarz}xmsg; print qq{$t};
This was the input:
.......... [FEN "1B3k2/2R1b3/4p1pp/2r1P1p1/6P1/7P/5PK1/8 w - - 4 34"] {Weiss am Zug} * .......... [FEN "1B6/1Q4bk/R5p1/1pp4p/8/1n5P/1P4PK/1q6 b - - 2 42"] {Weiss am Zug} * ........... [FEN "1Bn4r/1k3q2/1pp1bbp1/1N1p1p1r/Q2Pp3/6PN/PP2PPB1/K1R4R b - - 0 23 +"] {Weiss am Zug} * ........... [FEN "1K6/4kp2/1P4p1/7p/7P/1r3PP1/1p6/1R6 w - - 3 52"] {Weiss am Zug} *
The output was exactly the same, Weiss was not changed.
In reply to Re^2: Regex with condition
by OldChamp
in thread Regex with condition
by OldChamp
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |