Skip to content
Tcl Source Code Artifact [f9a133234e]
Login

Artifact [f9a133234e]

Artifact f9a133234eafc7402f9cf311d10519de464a25f8:

Ticket change [f9a133234e] - Ticket [05beaa6eef4fdb97|05beaa6eef] <i>regexp fails to match braces inside a character class</i> status still Closed with 6 other changes by dkf on 2014-02-15 15:08:43.
D 2014-02-15T15:08:43.880
J closedate 2456704.13106343
J closer dkf
J icomment I'm\sconfused\sby\swhat\syou\sthought\syou\swere\smatching.\sIn\sparticular,\sI\ssuspect\sthat\sthe\sstring\syou\swere\s<i>matching\sagainst</i>\swas\snot\swhat\syou\sthought\sit\swas.\sAlso,\sit's\sreally\sbest\sto\sput\sthe\sclose\ssquare\sbracket\sat\sthe\sstart\sof\sa\smatch\sset,\sand\syou\sdon't\sneed\snearly\sso\smany\sbackslashes.\r\n<pre>\r\n%\sset\sptn\s{the\s([][{}\\w\\s]+)\stest}\r\nthe\s([][{}\\w\\s]+)\stest\r\n%\sregexp\s-inline\s$ptn\s{the\sabc\sdef\stest}\r\n{the\sabc\sdef\stest}\s{abc\sdef}\r\n%\sregexp\s-inline\s$ptn\s{the\sabc][def\stest}\r\n{the\sabc][def\stest}\s{abc][def}\r\n%\sregexp\s-inline\s$ptn\s{the\s[\stest}\r\n{the\s[\stest}\s{[}\r\n</pre>\r\nWhat\swere\syou\smeaning\sto\shave\sas\sthe\sstrings\syou\smatched\sagainst?\r\n<pre>\r\n%\sregexp\s-inline\s$ptn\s{the\sabc\\}\\{def\stest}\r\n%\sregexp\s-inline\s$ptn\s"the\sabc\\}\\{def\stest"\r\nthe\\\sabc\\}\\{def\\\stest\sabc\\}\\{def\r\n%\s#\sThat\slooks\sconfusing;\sonce\smore,\swith\slist\sextraction!\r\n%\sforeach\sbit\s[regexp\s-inline\s$ptn\s"the\sabc\\}\\{def\stest"]\s{puts\s[incr\si]=>$bit}\r\n1=>the\sabc}{def\stest\r\n2=>abc}{def\r\n%\sputs\s{the\sabc\\}\\{def\stest}\r\nthe\sabc\\}\\{def\stest\r\n%\sputs\s"the\sabc\\}\\{def\stest"\r\nthe\sabc}{def\stest\r\n</pre>\r\nThat\sis,\swere\syou\sintending\sto\shave\sa\sliteral\sbackslash\sin\sthe\smatch\sset?\sIn\scase\syou\swere,\shere's\sa\sworking,\sminimal\sversion.\s(Braces\saren't\sspecial\sto\sRE\scharacter\ssets\s<i>per\sse</i>\sbut\sthey\scan\sinteract\swith\show\syou're\squoting\sthe\sstring.)\r\n<pre>\r\n%\s<b>###\sNOTE\sTHE\sEXTRA\sPAIR\sOF\sBACKSLASHES;\sONLY\sDIFFERENCE!\s###</b>\r\n%\sset\sptn\s{the\s([][{}\\w\\s\\\\]+)\stest}\r\nthe\s([][{}\\w\\s\\\\]+)\stest\r\n%\sregexp\s-inline\s$ptn\s{the\sabc\\}\\{def\stest}\r\n{the\sabc\\}\\{def\stest}\s{abc\\}\\{def}\r\n</pre>\r\nSome\sgeneral\scomments.\sEmbedded\sunbalanced\sbraces\sbreak\sbrace-quoting\sof\sliterals.\sAlways\shave\s(since\sone\sof\sthe\svery\searliest\sversions).\sThis\sisn't\smuch\sof\san\sissue\snormally\sas\sthey're\spretty\srare\sexcept\sin\stest\sdata.\sThe\slist-quoting\sengine\scopes\sby\sswitching\sto\sa\sdifferent\squoting\sstyle,\sas\syou\smight\sguess\sfrom\sthe\soutput\straces\sabove.
J login dkf
J mimetype text/html
J username dkf
K 05beaa6eef4fdb97d6fb518f0508c108c010c548
U dkf
Z 797cbba2b95e9b392932bd569ebbd515