Mercurial Hosting > luan
diff website/src/manual.html.luan @ 1722:7d2ab44f7a59
remove String regex fns
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Fri, 29 Jul 2022 14:12:01 -0600 |
parents | 5c69d2e8bd75 |
children | ba43135bb98d |
line wrap: on
line diff
--- a/website/src/manual.html.luan Tue Jul 26 12:44:52 2022 -0600 +++ b/website/src/manual.html.luan Fri Jul 29 14:12:01 2022 -0600 @@ -2485,125 +2485,6 @@ <% end } - ["String.gmatch"] = { - title = "<code>String.gmatch (s, pattern)</code>" - content = function() -%> -<p> -Returns an iterator function that, -each time it is called, -returns the next captures from <code>pattern</code> (see <a href="http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html">Pattern</a>) -over the string <code>s</code>. -If <code>pattern</code> specifies no captures, -then the whole match is produced in each call. -</p> - -<p> -As an example, the following loop -will iterate over all the words from string <code>s</code>, -printing one per line: -</p> -<pre> - local s = "hello world from Lua" - for w in String.gmatch(s, [[\w+]]) do - print(w) - end -</pre> - -<p> -The next example collects all pairs <code>key=value</code> from the -given string into a table: -</p> -<pre> - local t = {} - local s = "from=world, to=Lua" - for k, v in String.gmatch(s, [[(\w+)=(\w+)]]) do - t[k] = v - end -</pre> - -<p> -For this function, a caret '<code>^</code>' at the start of a pattern does not -work as an anchor, as this would prevent the iteration. -</p> -<% - end - } - ["String.gsub"] = { - title = "<code>String.gsub (s, pattern, repl [, n])</code>" - content = function() -%> -<p> -Returns a copy of <code>s</code> -in which all (or the first <code>n</code>, if given) -occurrences of the <code>pattern</code> (see <a href="http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html">Pattern</a>) have been -replaced by a replacement string specified by <code>repl</code>, -which can be a string, a table, or a function. -<code>gsub</code> also returns, as its second value, -the total number of matches that occurred. -The name <code>gsub</code> comes from <em>Global SUBstitution</em>. -</p> - -<p> -If <code>repl</code> is a string, then its value is used for replacement. -The character <code>\</code> works as an escape character. -Any sequence in <code>repl</code> of the form <code>$<em>d</em></code>, -with <em>d</em> between 1 and 9, -stands for the value of the <em>d</em>-th captured substring. -The sequence <code>$0</code> stands for the whole match. -</p> - -<p> -If <code>repl</code> is a table, then the table is queried for every match, -using the first capture as the key. -</p> - -<p> -If <code>repl</code> is a function, then this function is called every time a -match occurs, with all captured substrings passed as arguments, -in order. -</p> - -<p> -In any case, -if the pattern specifies no captures, -then it behaves as if the whole pattern was inside a capture. -</p> - -<p> -If the value returned by the table query or by the function call -is not <b>nil</b>, -then it is used as the replacement string; -otherwise, if it is <b>nil</b>, -then there is no replacement -(that is, the original match is kept in the string). -</p> - -<p> -Here are some examples: -</p> -<pre> - x = String.gsub("hello world", [[(\w+)]], "$1 $1") - --> x="hello hello world world" - - x = String.gsub("hello world", [[\w+]], "$0 $0", 1) - --> x="hello hello world" - - x = String.gsub("hello world from Luan", [[(\w+)\s*(\w+)]], "$2 $1") - --> x="world hello Luan from" - - x = String.gsub("4+5 = $return 4+5$", [[\$(.*?)\$]], function (s) - return load(s)() - end) - --> x="4+5 = 9" - - local t = {name="lua", version="5.3"} - x = String.gsub("$name-$version.tar.gz", [[\$(\w+)]], t) - --> x="lua-5.3.tar.gz" -</pre> -<% - end - } ["String.lower"] = { title = "<code>String.lower (s)</code>" content = function() @@ -2616,39 +2497,6 @@ <% end } - ["String.match"] = { - title = "<code>String.match (s, pattern [, init])</code>" - content = function() -%> -<p> -Looks for the first <em>match</em> of -<code>pattern</code> (see <a href="http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html">Pattern</a>) in the string <code>s</code>. -If it finds one, then <code>match</code> returns -the captures from the pattern; -otherwise it returns <b>nil</b>. -If <code>pattern</code> specifies no captures, -then the whole match is returned. -A third, optional numerical argument <code>init</code> specifies -where to start the search; -its default value is 1 and can be negative. -</p> -<% - end - } - ["String.matches"] = { - title = "<code>String.matches (s, pattern)</code>" - content = function() -%> -<p> -Returns a boolean indicating whether the <code>pattern</code> can be found in string <code>s</code>. -This function is equivalent to -</p> -<pre> - return String.match(s,pattern) ~= nil -</pre> -<% - end - } ["String.regex"] = { title = "<code>String.regex (s)</code>" content = function()