Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^4: regex replace a string

by OldChamp (Acolyte)
on Nov 05, 2017 at 22:05 UTC ( #1202789=note: print w/replies, xml ) Need Help??


in reply to Re^3: regex replace a string (updated)
in thread regex replace a string

Thank you for your help Anomalous Monk, I have applied the substitions you proposed and every thing works fine

use strict; use warnings; my $text = do { local $/; <>; }; my %replacement = ( 'b' =>' Schwarz am Zug', 'w' => 'Weiß am Zug', ); ;; my $condition = qr{ \b (?: b | w) \b }xms; $text =~ s{ Event \s+ " \K [?] (?= " .*? FEN [^\n]* \s+ ($condition) \s+ -) } {$replacement{$1}}xmsg; print $text;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1202789]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (1)
As of 2022-10-01 04:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer my indexes to start at:




    Results (126 votes). Check out past polls.

    Notices?