Jose Alves de Castro wrote:
On Tue, 2004-08-24 at 15:16, Tim McGeary 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;

So that I am understanding this process, what does each part mean? I assume that the ^ means beginning of the variable... is that correct? What about "(?:" ?


The ^ means the beginning of the string in $scalar, indeed.

As for the rest, I decided to group "a", "an" and "the" with brackets,
or otherwise the regex would have been /^a|^an|^the/

Regarding the :? , that's just so variable $1 doesn't end up with
whatever was removed, as there was no need for that.

Search for "Non-capturing groupings" under perldoc perlretut, if you
need more information

Great! Thank you very much! :)

Tim


-- 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