[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] A question to Matthais



[First of all, since many English native speakers seem to make a genuine
 mistake rather than a typo on this word, my first name is *Matthias*, not
 "Matthais"]

mark@cheers.jsc.nasa.gov (Mark Manning/Metrica) writes:
In message <199702261639.KAA08811@sun.jsc.nasa.gov> you write:
>In Perl (or rather MacPerl),

No difference between the two in that respect.

> when Perl is performing a search on a pattern does it go from the beginning
> of the string to the end of the string or from the end to the beginning?

Both the search pattern and the string are generally examined from the
beginning to the end. For the string, this is necessary in order to deliver the
leftmost match possible. For nontrivial patterns, this is necessary to deliver
the correct (usually shortest) match.

For trivial patterns, there are search methods (Boyer-Moore) which examine the
string generally in a left to right manner, but test the individual characters
in a pattern right to left; I don't think this is applicable to nontrivial
patterns, though, so I suppose Perl doesn't use it.

There was a fascinating article about regexp matching in 2 past issues of the
Perl Journal.

Matthias

-----
Matthias Neeracher   <neeri@iis.ee.ethz.ch>   http://www.iis.ee.ethz.ch/~neeri
   "I'm set free to find a new illusion" -- Velvet Underground