S
Sandman
This works:
###
#!/usr/bin/perl
use strict;
use warnings;
my $string = "12.00 Simpsons 12.30 Fresh prince 14.00 Superbowl";
my @list = split / ?(?=\d\d\.\d\d)/, $string;
foreach (@list){
print "$_\n";
}
###
And outputs:
12.00 Simpsons
12.30 Fresh prince
14.00 Superbowl
This doesn't work:
###
#!/usr/bin/perl
use strict;
use warnings;
my $string = "author:Jane Smith institution:university of Cambridge year:1976";
my @list = split / ?(?=\w+/, $string;
foreach (@list){
print "$_\n";
}
###
It outputs:
a
u
t
h
o
r:Jane Smith
i
n
s
t
i
t
u
t
i
o
n:university of Cambridge
y
e
a
r:1976
What makes it so different? The range matching (\w+)? I thought only variable
length was forbidden in lookback, not in look forward, or am I misunderstanding
something completely?
###
#!/usr/bin/perl
use strict;
use warnings;
my $string = "12.00 Simpsons 12.30 Fresh prince 14.00 Superbowl";
my @list = split / ?(?=\d\d\.\d\d)/, $string;
foreach (@list){
print "$_\n";
}
###
And outputs:
12.00 Simpsons
12.30 Fresh prince
14.00 Superbowl
This doesn't work:
###
#!/usr/bin/perl
use strict;
use warnings;
my $string = "author:Jane Smith institution:university of Cambridge year:1976";
my @list = split / ?(?=\w+/, $string;
foreach (@list){
print "$_\n";
}
###
It outputs:
a
u
t
h
o
r:Jane Smith
i
n
s
t
i
t
u
t
i
o
n:university of Cambridge
y
e
a
r:1976
What makes it so different? The range matching (\w+)? I thought only variable
length was forbidden in lookback, not in look forward, or am I misunderstanding
something completely?