Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Regular Expressions

by AnomalousMonk (Archbishop)
on Jul 07, 2015 at 00:44 UTC ( [id://1133478]=note: print w/replies, xml ) Need Help??


in reply to Regular Expressions

Yes, you show no code, the problem description is very vague, you don't say with what the words are to be 'replaced', and yes, this does smell like homework, but...

c:\@Work\Perl\monks>perl -wMstrict -le "my $s = 'In the table above, the characters themselves, in the first +column, are links to descriptions of characters'; print qq{'$s'}; ;; my %xlate = qw(table tooble characters croobles selves others first second +links loonks); ;; my ($word) = map qr{ $_ }xms, join q{ | }, keys %xlate ; print $word; ;; $s =~ s{ ($word) }{$xlate{$1}}xmsg; print qq{'$s'}; " 'In the table above, the characters themselves, in the first column, a +re links to descriptions of characters' (?msx-i: first | selves | table | links | characters ) 'In the tooble above, the croobles themothers, in the second column, a +re loonks to descriptions of croobles'

Update: Caution: long lines: some wraparound may have occurred.


Give a man a fish:  <%-(-(-(-<

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-04-19 15:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found