On Tue, 2004-08-24 at 16:19, 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"
> 
> 2. It doesn't remove whitespace after the word, so "The Widget Primer"
> becomes " Widget Primer", which won't sort with the w's, due to the leading
> blank.
> 
> Perhaps:
> 
>    $scalar =~ s/^(a|an|the)\s*\b//i;
> 
> would work better.

You're absolutely right. I think this is a sign that I need to go out,
eat and drink something, breath some fresh air, etc.

-- 
José Alves de Castro <[EMAIL PROTECTED]>
  http://natura.di.uminho.pt/~jac

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to