Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re^3: Regex with conditionby AnomalousMonk (Archbishop) |
on Nov 19, 2015 at 20:39 UTC ( [id://1148168]=note: print w/replies, xml ) | Need Help?? |
In my reply above, I wrote However, also note that if the "random amount of other text" preceding the 'b' in a trigger line may contain any whitespace, then theIn the OP, a typical 'b' line was '1n5P/1P4PK/1q6 b - - 2 42"]' In the post to which this is a reply, a typical 'b' line is '[FEN "1B6/1Q4bk/R5p1/1pp4p/8/1n5P/1P4PK/1q6 b - - 2 42"]' with more than one whitespace character before the 'b'. Accordingly, I have altered the $pre regex to my $pre = qr{ \S+ \s \S+ \s }xms; (This is not what I would consider a "robust" regex, but you will have to provide a regex that best matches your data if you wish an improvement.)
In addition, in the OP a typical 'Weiss' line had leading whitespace; in the most recent post, it has none. Accordingly, I have altered the $post regex to I have downloaded your latest data to my file 1148125.dat. With the changes above and your latest data: At last, Weiss has changed. Give a man a fish: <%-{-{-{-<
In Section
Seekers of Perl Wisdom
|
|