in reply to regexp: least inclusive match?
If the marker is a plain string (as in the example, without regex specials), substr and rindex ought to do the job:
my $idx = rindex($text, "Tags"); if ($idx > -1) { substr($text, $idx) = ''; }
Otherwise you could for instance take advantage of * being greedy from the start:
$text =~ s/(.*)Tags.*/$1/s;
print "Just another Perl ${\(trickster and hacker)},"
The Sidhekin proves Sidhe did it!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: regexp: least inclusive match?
by varian (Chaplain) on Mar 03, 2007 at 11:03 UTC |
In Section
Seekers of Perl Wisdom