<i>exact match is greedy by reluctant exact match quantifier</i> status still Open with 6 other changes
by
.
D 2019-11-22T14:52:40.641
J closer nobody
J comment Possible\sbug,\scause\sIMO\sthat\sshould\smatch\sthe\ssame:\r\nOr\sa\sdocumentation\sbug\s-\saccording\sto\sdocumentation\s"{m}?"\sis\sungreedy\squantifier.\r\n\r\n%\sregexp\s-inline\s{((?:ab|abc){1}?)(cd|d){1}?}\sabcd\r\nabcd\sabc\sd\r\n%\sregexp\s-inline\s{((?:ab|abc){1,1}?)(cd|d){1,1}?}\sabcd\r\nabcd\sab\scd
J icomment A\sfresh\sconcern\sregarding\sthe\sissue\sand\snew\sfindings\safter\sdiscussion\sin\stclchat\swith\spooryorick.\r\n\r\nThe\sissue\scould\sbe\sexplained\swith\sfollowing\ssentence\sfrom\sthe\sdocumentation:<br/>\r\n<blockquote><i>A\squantified\satom\swith\squantifier\s{m}\sor\s{m}?\shas\sthe\ssame\spreference\s(possibly\snone)\sas\sthe\satom\sitself.\sA\squantified\satom\swith\sother\snormal\squantifiers\s(including\s{m,n}\swith\sm\sequal\sto\sn)\sprefers\slongest\smatch.\sA\squantified\satom\swith\sother\snon-greedy\squantifiers\s(including\s{m,n}?\swith\sm\sequal\sto\sn)\sprefers\sshortest\smatch.</i></blockquote>\r\n\r\nBut\sthe\sfact\sthat\s<code>{m,n}</code>\sprefers\sthe\sshortest\smatch\sdoesn't\smean\sthat\sthe\ssub-expression\sit\sis\sapplied\sto\sshould\sprefer\sthe\sshortest\smatch\s(at\sleast,\sit\sdoesn't\snecessarily\smean\sthat).\r\n\r\n<hr>\r\n\r\nAnother\sinteresting\sset\sof\sexamples\swhich\scan\sbe\srelated\sto\sthe\ssame\sissue:\r\n<pre>\r\n\s\s\s\s%\sregexp\s-inline\s{(t*?)?}\sttt\r\n\s\s\s\sttt\s<b\sstyle="color:green">t</b><b\sstyle="color:red">tt</b>\r\n\s\s\s\s%\sregexp\s-inline\s{(t*)?}\sttt\r\n\s\s\s\sttt\sttt\r\n</pre>\r\nAlthough\sit\sbehaves\slike\sdescribed\sin\sthe\sdocumentation:<br/>\r\n<blockquote><i>A\sbranch\shas\sthe\ssame\spreference\sas\sthe\sfirst\squantified\satom\sin\sit\swhich\shas\sa\spreference.\sAn\sRE\sconsisting\sof\stwo\sor\smore\sbranches\sconnected\sby\sthe\s|\soperator\sprefers\slongest\smatch.</i></blockquote>\r\n\r\nBut\sit\sdoes\snot\sexplain\swhy\sthe\sgroup\sis\sexpanded\sto\sthe\swhole\smatch,\sas\swell\sas\sthe\sdifference\sto\sthis\scounter-example:\r\n<pre>\r\n\s\s\s\s%\sregexp\s-all\s-inline\s{(t)*}\sttt\r\n\s\s\s\sttt\s<b\sstyle="color:green">t</b>\r\n</pre>\r\n\r\nSo\sthe\schange\sto\sgreedy\squantifier\sof\sRE\sseems\sto\saffect\scapturing\sbehavior\sof\s(initially)\snon-greedy\sgroup,\scompared\sto\s(initially)\sgreedy\sgroup.\r\n\r\n<hr>\r\n\r\nFWIW,\smaybe\sfollowing\swould\sexplain\sthe\sreason\s(or\srather\sthe\snecessity)\swhy\sor\sfor\swhich\scases\sthe\ssub-branch\s(group)\scould\sbe\snon-greedy\s(why\sthis\scan\sbe\sexpected\sor\sused):\r\n<pre>\r\n\s\s\s\s%\sregexp\s-inline\s{(t*?(\\w+))?}\sttxx\r\n\s\s\s\sttxx\sttxx\sttxx\r\n\s\s\s\s%\sregexp\s-inline\s{(t*(\\w+))?}\sttxx\r\n\s\s\s\sttxx\sttxx\sxx\r\n</pre>\r\nBut\sthat\sall\sstill\sdon't\sexplain\sthe\sgrowth\sof\scaptured\snon-greedy\sgroup\sto\sthe\swhole\smatch.
J login sebres
J mimetype text/x-fossil-wiki
J severity Minor
K 3574242fffffffffffffffffffffffffffffffff
U sebres
Z cab8b0e5944c446371d8166976f718a6