On Wed, 8 May 2024 at 17:04, Marcus Comstedt (ACROSS) (Hail Ilpalazzo!) @ Pike (-) developers forum 10353@lyskom.lysator.liu.se wrote:
The behaviour of match() when there is not exactly one thing matching seems a bit weird in general:
Pike v9.0 release 2 running Hilfe v3.5 (Incremental Pike Frontend)
object buf = Stdio.Buffer("#4,7"); buf->match("#%d,%d");
(1) Result: 11
That IS a bit weird, although not undocumented - if it matches multiple strings, it returns their concatenation. But since it's defined as returning the *sum*, this quirk happens. It's designed for a single match pattern and for that it generally does fine.
Definitely an amusing consequence though!
ChrisA