Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^3: RegEx ignoring intervening characters?

by webfiend (Vicar)
on Jan 19, 2007 at 21:59 UTC ( [id://595611]=note: print w/replies, xml ) Need Help??


in reply to Re^2: RegEx ignoring intervening characters?
in thread RegEx ignoring intervening characters?

(my $x = $s) =~ s/[^A-Z]//g;

That assigns the value of $s to $x, then performs the substitution on $x. $s is left unmolested.

$ perl -e 'chomp($orig = <STDIN>); ($tmp = $orig) =~ s/[^A-Z]//g; prin +t "Copy: $tmp\nOriginal: $orig\n";' WeDfT Copy: WDT Original: WeDfT

So it's a perfectly valid element of your solution

Update: Hey, how about I actually show it in action?

use strict; use warnings; chomp(my $input = <STDIN>); (my $test = $input) =~ s/[^A-Z]//g; if ($test =~ /ABCD/) { print "'$input' matches!\n"; } else { print "'$input' does not match.\n"; }
$ perl test.pl WaFFe 'WaFFe' does not match. $ [bwisti@w3d145 tmp]$ perl test.pl AeBwaffleCfrenchtoastD 'AeBwaffleCfrenchtoastD' matches!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2024-04-24 09:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found