in reply to Leaking Regex Captures
#!/usr/bin/perl -w use strict; while (<DATA>) { print "testing: $_"; chomp; my @digits = m/\d+/g; print "digits only: @digits\n"; my @numletters = m/\d[^\d]+/g; print "digits_and_letters:@numletters\n\n"; } #Prints: #testing: 1c #digits only: 1 #digits_and_letters:1c # #testing: 2w #digits only: 2 #digits_and_letters:2w # #testing: 2c3w #digits only: 2 3 #digits_and_letters:2c 3w # #testing: 1w1w #digits only: 1 1 #digits_and_letters:1w 1w # #testing: 1w2r #digits only: 1 2 #digits_and_letters:1w 2r # #testing: 2r1c #digits only: 2 1 #digits_and_letters:2r 1c __DATA__ 1c 2w 2c3w 1w1w 1w2r 2r1c
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Leaking Regex Captures
by SuicideJunkie (Vicar) on Aug 05, 2009 at 15:33 UTC | |
by Marshall (Canon) on Aug 05, 2009 at 16:07 UTC | |
by SuicideJunkie (Vicar) on Aug 05, 2009 at 17:02 UTC | |
by Marshall (Canon) on Aug 06, 2009 at 22:29 UTC |