- or download this
is($actual, $expected, $descriptionOfWhatYouTried);
...
# to check what got captured by a regular expression
is(eval { 'abcdef' =~ /^(\w+)/; $1 }, 'ab', q{tried /^\w+/});
- or download this
not ok 1 - tried /^\w+/
# Failed test 'tried /^\w+/'
...
# expected: 'ab'
1..1
# Looks like you failed 1 test of 1.
- or download this
#changed is to isnt
#This doesn't work. Captures 'abcdef' instead of just 'ab'
isnt(eval { 'abcdef' =~ /^(\w+)/; $1 }, 'ab', q{tried /^\w+/});
- or download this
#using perl MyExperiments.pl
...
MyExperiments.pl....ok
All tests successful.
Files=1, Tests=10, 0 wallclock secs ( 0.05 cusr + 0.04 csys = 0.09
+CPU)
- or download this
use strict;
use warnings;
...
#BINGO! this worked
is(eval {'abcdeee' =~ /(.)(\1+)/;"$1$2"}, 'eee', q{using /(.)(\1+)/;"$
+1$2"});
- or download this
use strict;
use warnings;
...
regexRepeat('abcdeeef', 'eee'); #only one to find
regexRepeat('abbb;eeef', 'bbb'); #should find first