A little extra
#!/usr/bin/perl
use strict;
my (@anyname) = ('stuff Newbie more stuff',
'stuff Neyoubie more stuff',
'stuff Niwbie more stuff',
'stuff Newbie otherstuff Newbie more stuff'
);
foreach my $string (@anyname) {
print "$string --> ";
$string =~ s/Ne.*bie//;
print "$string\n";
}
print "\n";
@anyname = ('stuff Newbie more stuff',
'stuff Neyoubie more stuff',
'stuff Niwbie more stuff',
'stuff Newbie otherstuff Newbie more stuff'
);
foreach my $string (@anyname) {
print "$string --> ";
## use the non-greedy form
$string =~ s/Ne.*?bie//;
print "$string\n";
}
exit;
Results:
stuff Newbie more stuff --> stuff more stuff
stuff Neyoubie more stuff --> stuff more stuff
stuff Niwbie more stuff --> stuff Niwbie more stuff
stuff Newbie otherstuff Newbie more stuff --> stuff more stuff
stuff Newbie more stuff --> stuff more stuff
stuff Neyoubie more stuff --> stuff more stuff
stuff Niwbie more stuff --> stuff Niwbie more stuff
stuff Newbie otherstuff Newbie more stuff --> stuff otherstuff Newbie more stuff
|