"description": "Documentation for the Lua string standard library.\nFrom <a href=\"https://www.lua.org/manual/5.1/\">Lua 5.1 Reference Manual</a>\nby Roberto Ierusalimschy, Luiz Henrique de Figueiredo, Waldemar Celes.\nCopyright © 2006-2012 Lua.org, PUC-Rio.\nFreely available under the terms of the <a href=\"https://www.lua.org/license.html\">Lua license</a>.\n<h3>Patterns</h3>\n<em>Character Class:</em>\nA character class is used to represent a set of characters.\nThe following combinations are allowed in describing a character class:\n<dl>\n<dt>x</dt>\n<dd>(where x is not one of the <em>magic characters</em> <code>^$()%.[]*+-?</code>)\n represents the character <em>x</em> itself.</dd>\n<dt><code>.</code></dt>\n<dd>(a dot) represents all characters.</dd>\n<dt><code>%a</code></dt>\n<dd>represents all letters.</dd>\n<dt><code>%c</code></dt>\n<dd>represents all control characters.</dd>\n<dt><code>%d</code></dt>\n<dd>represents all digits.</dd>\n<dt><code>%l</code></dt>\n<dd>represents all lowercase letters.</dd>\n<dt><code>%p</code></dt>\n<dd>represents all punctuation characters.</dd>\n<dt><code>%s</code></dt>\n<dd>represents all space characters.</dd>\n<dt><code>%u</code></dt>\n<dd>represents all uppercase letters.</dd>\n<dt><code>%w</code></dt>\n<dd>represents all alphanumeric characters.</dd>\n<dt><code>%x</code></dt>\n<dd>represents all hexadecimal digits.</dd>\n<dt><code>%z</code></dt>\n<dd>represents the character with representation 0.</dd>\n<dt><code>%x</code></dt>\n<dd>(where x is any non-alphanumeric character) represents the character x.\n This is the standard way to escape the magic characters.\n Any punctuation character (even the non magic) can be preceded by a '%'\n when used to represent itself in a pattern.</dd>\n<dt><code>[set]</code></dt>\n<dd>represents the class which is the union of all characters in set.\n A range of characters can be specified by separating the end characters\n of the range with a '-'.\n All classes <code>%</code><em>x</em> described above can also be used as components in set.\n All other characters in set represent themselves.\n For example, <code>[%w_]</code> (or <code>[_%w]</code>) represents all alphanumeric characters\n plus the underscore, <code>[0-7]</code> represents the octal digits,\n and <code>[0-7%l%-]</code> represents the octal digits plus the lowercase letters\n plus the '-' character.</dd>\n</dl>\nThe interaction between ranges and classes is not defined.\n Therefore, patterns like <code>[%a-z]</code> or <code>[a-%%]</code> have no meaning.\n<dl>\n<dt><code>[^set]</code></dt>\n<dd>represents the complement of set,\n where set is interpreted as above.</dd>\n</dl>\nFor all classes represented by single letters (<code>%a</code>, <code>%c</code>, etc.),\nthe corresponding uppercase letter represents the complement of the class.\nFor instance, <code>%S</code> represents all non-space characters.\nThe definitions of letter, space, and other character groups\ndepend on the current locale. In particular, the class <code>[a-z]</code> may not be\nequivalent to <code>%l</code>.\n<em>Pattern Item:</em>\nA pattern item can be\n<ul>\n<li>\na single character class, which matches any single character in the class;\n</li>\n<li>\na single character class followed by '*',\n which matches 0 or more repetitions of characters in the class.\n These repetition items will always match the longest possible sequence;\n</li>\n<li>\na single character class followed by '+',\n which matches 1 or more repetitions of characters in the class.\n These repetition items will always match the longest possible sequence;\n</li>\n<li>\na single character class followed by '-',\n which also matches 0 or more repetitions of characters in the class.\n Unlike '*', these repetition items will always match the <em>shortest</em>\n possible sequence;\n</li>\n<li>\na single character class followed by '?',\n which matches 0 or 1 occurrence of a character in the class;\n</li>\n<li>\n<code>%n</code>, for n between 1 and 9; such item matches a substring equal to the\n n-th captured string (see below);\n</li>\n<li>\n<code>%bxy</code>, where x and y are two distinct characters;\n such item matches strings that start with x, end with y,\n and where the x and y are <em>balanced</em>.\n This means that, if one reads the string from left to right,\n counting +1 for an x and -1 for a y,\n the ending y is the first y where the count reaches 0.\n For instance, the item <code>%b()</code> matches expressions with balanced parentheses.\n</li>\n</ul>\n<em>Pattern:</em>\nA pattern is a sequence of pattern items.\nA '^' at the beginning of a pattern anchors the match at the\nbeginning of the subject string.\nA '$' at the end of a pattern anchors the match at the\nend of the subject string.\nAt other positions, '^' and '$' have no special meaning and represent themselves.\n<em>Captures:</em>\nA pattern can contain sub-patterns enclosed in parentheses;\nthey describe captures.\nWhen a match succeeds, the substrings of the subject string\nthat match captures are stored (<em>captured</em>) for future use.\nCaptures are numbered according to their left parentheses.\nFor instance, in the pattern <code>\"(a*(.)%w(%s*))\"</code>,\nthe part of the string matching <code>\"a*(.)%w(%s*)\"</code> is\nstored as the first capture (and therefore has number 1);\nthe character matching \".\" is captured with number 2,\nand the part matching \"%s*\" has number 3.\nAs a special case, the empty capture <code>()</code> captures\nthe current string position (a number).\nFor instance, if we apply the pattern <code>\"()aa()\"</code> on the\nstring <code>\"flaaap\"</code>, there will be two captures: 3 and 5.\nA pattern cannot contain embedded zeros. Use <code>%z</code> instead.",
0 commit comments