
japhy
Enthusiast
/ Moderator
Jun 1, 2000, 5:08 PM
Post #6 of 8
(11555 views)
|
monocle - you can use characters OTHER than / for your s/// and m// and tr///. To use $1, $2, etc., you need to parenthesize sub-patterns of your regular expressions: <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> "8675309 jenny" =~ /(\d+)\s+(\w+)/; # $1 is 8675309 # $2 is "jenny" # but these vars are wiped out right before # each new regular expression ($number,$name) = "8675309 jenny" =~ /(\d+)\s+(\w+)/; # $number is 8675309 # $name is "jenny" # and these vars last until you change them # or they go out of scope </pre><HR></BLOCKQUOTE>
|