>>>> "Aidan" == Aidan Kehoe
<kehoea(a)parhasard.net> writes:
Aidan> Well-defined by Perl and other regexp engines, you mean?
No, well-defined in abstract algebra and language theory. The rest of
that crap is mere implementation.
Aidan> Its Perl equivalent does do what you say, though (ignoring
Aidan> that your example result didn’t pay attention to the
Aidan> starting anchor empty match);
There is no empty match at the starting anchor, there is a nonnull
match there. IMO, Perl is broken. So is PHP. Maybe we'd better
check POSIX, I could very likely be wrong: the Perl guys are unlikely
to screw up on regexps! On second thought, Python gives the answer I
prefer:
>> from re import sub
>> sub ("a*", "b", "ac")
'bcb'
>>
and furthermore defines the operation in language theory terms, not
via a reference implementation:
`sub(pattern, repl, string[, count])'
Return the string obtained by replacing the leftmost
non-overlapping occurrences of PATTERN in STRING by the replacement
REPL. If the pattern isn't found, STRING is returned unchanged.
("Leftmost non-overlapping" actually means "if matches overlap, the
leftmost is replaced, and any matches that overlapped it are ignored",
according to the Python implementation:
>> sub ("ac|ca", "b", "acaca")
'bba'
>>
That's what I want it to mean. ;-)
> We should check current GNU and notify them if they're
busted.
Aidan> [They are.]
> 21.4 will need these patches, I'm pretty sure.
Aidan> Whee.
Thanks for checking! Now comes the fun.
--
Institute of Policy and Planning Sciences
http://turnbull.sk.tsukuba.ac.jp
University of Tsukuba Tennodai 1-1-1 Tsukuba 305-8573 JAPAN
Ask not how you can "do" free software business;
ask what your business can "do for" free software.