John W. Krahn wrote:
> Bob Showalter wrote:
> > Jose Alves de Castro wrote:
> > 
> > > On Tue, 2004-08-24 at 15:04, Tim McGeary wrote:
> > > 
> > > > I need to pull out articles "a", "an", and "the" from the
> > > > beginning of title strings so that they sort properly in MySQL.
> > > > What is the best way to accomplish that if I have a single
> > > > $scalar with the whole title in it?
> > > 
> > > I would go with substitutions:
> > > 
> > > $scalar =~ s/^(?:a|an|the)//i;
> > 
> > Two problems:
> > 
> > 1. This doesn't remove just the whole words; it removes parts of
> > words as well. i.e. "Analyzing Widgets" would become "alyzing
> > Widgets" 
> 
> Actually it would become "nalyzing Widgets" because 'a' is the first
> alternative.  :-)

Smarty pants :~) 

My brain said "longest, leftmost", but the short-circuiting behavior is
clearly documented in perldoc perlre. If the alternation is written as
(an?|the), the "an" is matched.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to