lua-users home
lua-l archive

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


I don't think this is a bug. I think it is expected behaviour. (At least,
it is the behaviour I would expect.)

OK, this behavior may be selectable, but I think
the double-matching is not suitable for Lua.

Double-matching rule is not intuitively for me.
In case below, the empty string after "c" seems to be
already matched at the first match.
  string.gsub("abc", ".*" "x")

And I think, it's easier to use single-matching rule
than avoiding double-matching.
Maybe I can avoid it in almost all cases, but it seems
to be complicated.
Is there any advantage for double-matching?

This behavior is not explicitly written in the reference
manual, at least I read.
If this is a selection of the Lua specification (or
the implementation), I want the author to add the
description of the behavior to the `Pattern' section.


P.S.
This is redundant, I know...
$ echo test | sed 's/.*/x/g'
x
$ echo test | awk '{gsub(".*","x");print($0)}'
x
$ perl -e '$a="test";$a=~s/.*/x/g;print($a,"\n");'
xx
$ php -r 'echo ereg_replace(".*","x","test"),"\n";'
xx

--
asakawa