<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jun 17, 2013 at 4:54 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">luigi scarso <<a href="mailto:luigi.scarso@gmail.com">luigi.scarso@gmail.com</a>> a écrit:<br>

<div><div class="h5">> On Mon, Jun 17, 2013 at 2:43 PM, Paul Isambert <<a href="mailto:zappathustra@free.fr">zappathustra@free.fr</a>> wrote:<br>
><br>
> > Hello all,<br>
> ><br>
> > This is not really a LuaTeX question, but I ask it here anyway since a<br>
> > lot of knowledgeable people read this list.<br>
> ><br>
> > I’ve been surprised to discover that<br>
> ><br>
> >     print(string.gsub('abc', '.*', '(%0)'))<br>
> ><br>
> > returns<br>
> ><br>
> >     (abc)()<br>
> ><br>
> > (similarly, “string.gmatch('abc', '.*')” returns two matches). I’d<br>
> > expect<br>
> ><br>
> >     (abc)<br>
> ><br>
> ><br>
><br>
> myabe this can help<br>
><br>
> > print(string.gsub("abc","%s*","(%0)"))<br>
> ()a()b()c()    4<br>
><br>
> > print(string.gsub("abc","%S*","(%0)"))<br>
> (abc)()    2<br>
><br>
> """<br>
> A pattern item can be<br>
><br>
> a single character class followed by '*', which matches 0 or more<br>
> repetitions of characters in the class. These repetition items will always<br>
> match the longest possible sequence;<br>
> """<br>
<br>
</div></div>Thank you Luigi, but “*” has the same definition in other languages,<br>
including those where there is no match on a final empty string.<br>
<br>
As for your first example, all languages behave the same as far as I<br>
can tell, as expected.<br>
<br>
Best,<br>
Paul<br>
<br>
</blockquote></div><br>$ perl -e '$x="abc"; @w=($x=~ /(.*)/g);  print "tot. matches:", scalar(@w), "  matches:($w[0])($w[1])\n"'<br>tot. matches:2  matches:(abc)()<br><br clear="all">
$ perl -e '$x="abc"; @w=($x=~ /(.*)/);  print "tot. matches:", scalar(@w), "  matches:($w[0])($w[1])\n"'<br>tot. matches:1  matches:(abc)()<br><br></div><div class="gmail_extra">in perl<br>
"the modifier //g stands for global matching and allows the matching operator to match within a string as many times as possible"<br>and I think it corresponds to <br>"These repetition items will always match the longest possible sequence;"<br>
</div><div class="gmail_extra">of pattern.<br><br></div><div class="gmail_extra">-- <br>luigi<br>
</div></div>