Re: Transliteration preferring longest match

2005-12-16 Thread Ruud H.G. van Tol
John Macdonald: [trans] If a shorter rule is allowed to match first, then the longer rule can be removed from the match set, at least for constant string matches. It is not about the length of the rules, but about the length of the matches. If both \s+ and \h+ match the same length, should

Re: Transliteration preferring longest match

2005-12-16 Thread Larry Wall
On Fri, Dec 16, 2005 at 01:29:11PM +0100, Ruud H.G. van Tol wrote: : John Macdonald: : : [trans] : If a shorter rule is allowed to match first, then the longer : rule can be removed from the match set, at least for constant : string matches. : : It is not about the length of the rules, but

Re: Transliteration preferring longest match

2005-12-16 Thread Larry Wall
On Fri, Dec 16, 2005 at 09:14:52AM -0800, Larry Wall wrote: : It would be a useful exercise to write tr/// in terms of s///. : It occurs to me that it'd be awfully useful to have a kind of hash : that returns any unmatched key unchanged. Actually, in this case it's handled by the fact that the

Re: Transliteration preferring longest match

2005-12-16 Thread Ruud H.G. van Tol
Larry Wall: Ruud H.G. van Tol: John Macdonald: [trans] If a shorter rule is allowed to match first, then the longer rule can be removed from the match set, at least for constant string matches. It is not about the length of the rules, but about the length of the matches. They're the

Re: Transliteration preferring longest match

2005-12-16 Thread Brad Bowman
This is only about transliteration (tr///), not rules in general. So you are only matching a fixing set of strings at a certain position. If one string is the prefix of another, the longer is preferred. If there are two identical match strings, the replacement corresponding to the first is used.

Re: Transliteration preferring longest match

2005-12-15 Thread Luke Palmer
On 12/15/05, Brad Bowman [EMAIL PROTECTED] wrote: Why does the longest input sequence win? Is it for some consistency that that I'm not seeing? Some exceedingly common use case? The rule seems unnecessarily restrictive. Hmm. Good point. You see, the longest token wins because that's an

Re: Transliteration preferring longest match

2005-12-15 Thread Larry Wall
On Thu, Dec 15, 2005 at 06:50:19PM +0100, Brad Bowman wrote: : : Hi, : : S05 describes an array version of trans for transliteration: : ( http://dev.perl.org/perl6/doc/design/syn/S05.html#Transliteration ) : : The array version can map one-or-more characters to one-or-more : characters: :

Re: Transliteration preferring longest match

2005-12-15 Thread John Macdonald
On Thu, Dec 15, 2005 at 09:56:09PM +, Luke Palmer wrote: On 12/15/05, Brad Bowman [EMAIL PROTECTED] wrote: Why does the longest input sequence win? Is it for some consistency that that I'm not seeing? Some exceedingly common use case? The rule seems unnecessarily restrictive.