<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jun 17, 2013 at 11:51 PM, Paul Isambert <span dir="ltr"><<a href="mailto:zappathustra@free.fr" target="_blank">zappathustra@free.fr</a>></span> wrote:<br>






<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>luigi scarso <<a href="mailto:luigi.scarso@gmail.com" target="_blank">luigi.scarso@gmail.com</a>> a écrit:<br>







</div><div>> On Mon, Jun 17, 2013 at 7:24 PM, Paul Isambert <<a href="mailto:zappathustra@free.fr" target="_blank">zappathustra@free.fr</a>> wrote:<br>
><br>
> ><br>
> > still prints “(abc)()” (the “$” is included to make it comparable to<br>
> > “.*”), whereas the equivalent<br>
> ><br>
> >     echo substitute('abc', '.\{-}$', '(\0)', 'g')<br>
> ><br>
> I don't know vim,<br>
<br>
</div>Bad Luigi.<br>
<div><br>
>                   but does zero-width<br>
> <a href="http://vimdoc.sourceforge.net/htmldoc/pattern.html" target="_blank">http://vimdoc.sourceforge.net/htmldoc/pattern.html</a><br>
> <a href="http://davidchuprogramming.blogspot.it/2012/04/vim-tip-not-containing-pattern-2.html" target="_blank">http://davidchuprogramming.blogspot.it/2012/04/vim-tip-not-containing-pattern-2.html</a><br>
> have some influence ?<br>
<br>
</div>I don’t think so. As expressed in the discussion pointed to by Dirk,<br>
the difference seems to be one of implementation not of semantic<br>
difference between similar operators (although it actually makes a<br>
difference). Dirk even formalized all that (in the same discussion),<br>
and if I understood correctly the punchline is (as long as you agree<br>
with Dirk, as I do): substrings should be closed intervals! Which<br>
makes a nice motto, too bad Lua doesn’t endorse it.<br>
<br>
Thanks,<br>
Paul<br>
<br>
</blockquote></div>reading <br><a href="http://lua-users.org/lists/lua-l/2013-04/msg00865.html" target="_blank">http://lua-users.org/lists/lua-l/2013-04/msg00865.html</a><br clear="all"></div><div class="gmail_extra">I can say that agree, but coming from perl I also say that I find Lua natural for me.<br>






</div><div class="gmail_extra">When I have an unexpected  behaviour I think then pattern with ϵ, the zero width string, <br>eg  abc as <br></div><div class="gmail_extra">ϵaϵbϵcϵ<br></div><div class="gmail_extra">and in this way also your prev. example looks reasonable (greedy and global match considered).<br>



</div><div class="gmail_extra"><br>Or:<br>print((string.gsub(";a;", "a*", "ITEM")))<br>ITEM;ITEMITEM;ITEM<br><br></div><div class="gmail_extra">target string is  <br>ϵ;ϵaϵ;ϵ<br></div><div class="gmail_extra">


pattern  is a* = ϵ|a+</div><div class="gmail_extra">replacement is ITEM<br></div><div class="gmail_extra">If we rewrite the target as <br>target=[ϵ][;][ϵ][a][ϵ][;][ϵ]<br></div><div class="gmail_extra">we have <br></div><div class="gmail_extra">

ϵ=target[1] match  => ITEM<br>;=target[2] no match => ;<br>
ϵ;target[3] match => ITEM<br>aϵ=target[4] & target[5] match (greedy) => ITEM<br>;=target[6] no match => ;<br>ϵ=target[7]  match => ITEM<br><br></div><div class="gmail_extra"><br>Given that there is a pcre lib I tend to consider perl as reference --- but I also know that many find regex complicate to understand/implement, <br>

so I don't  complain when Lua says that <br></div><div class="gmail_extra">its regex are not perl or posix compatible because it wants to maintain the size of the code low.<br>
</div><div class="gmail_extra"><br>How do you reproduce the same behaviour of Lua string.gsub("abc"...  <br>
</div><div class="gmail_extra">with Vim ?<br></div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><br><div class="gmail_extra">-- <br>luigi<br>
</div></div>