.
D 2014-12-29T21:43:14.182
J icomment >\sHi,\sI\shave\sseen\sa\sbug\sin\sregexp\smatching.\s\r\nNo,\syou\sdidn't.\s;)\r\n\r\n>\sI\sverified\sVS\sexternal\sregexp\sengines\sthat\sindeed\sim\snot\smistaken.\r\nOther\sengines\sare\sirrelevant\shere.\r\n\r\nFrom\sman\sre_syntax:\r\n---\r\nIn\sthe\sevent\sthat\san\sRE\scould\smatch\smore\sthan\sone\ssubstring\sof\sa\sgiven\sstring,\sthe\sRE\smatches\sthe\sone\sstarting\searliest\sin\sthe\sstring.\sIf\sthe\sRE\scould\smatch\smore\sthan\sone\ssubstring\sstarting\sat\sthat\spoint,\sits\schoice\sis\sdetermined\sby\sits\spreference:\seither\sthe\slongest\ssubstring,\sor\sthe\sshortest.\r\n\r\nMost\satoms,\sand\sall\sconstraints,\shave\sno\spreference.\sA\sparenthesized\sRE\shas\sthe\ssame\spreference\s(possibly\snone)\sas\sthe\sRE.\sA\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.\sA\sbranch\shas\sthe\ssame\spreference\sas\sthe\sfirst\squantified\satom\sin\sit\swhich\shas\sa\spreference.\s\r\n---\r\nYour\sRE\sstarts\swith\squantified\satom\swith\snormal\squantifier\s(\\n?),\sso\sthis\satom\sprefers\slongest\smatch.\sAs\syour\sRE\sconsists\sof\ssingle\sbranch,\s"it\shas\sthe\ssame\spreference\sas\sthe\sfirst\squantified\satom\sin\sit\swhich\shas\sa\spreference"\s---\slongest\smatch.\r\n\r\nSo,\sit's\snot\sa\sbug.\sSo,\syour\sRE\sshould\shave\sbeen:\s\\n??(0+?)
J login ysch
J mimetype text/plain
K 700ac47ece488c90836eac2e459ad29e6f329b6e
U ysch
Z 6873bb334810ad31fbda0d157273d828