Regular expressions: Difference between revisions

m (→‎{{header|Wren}}: Minor tidy)
 
(One intermediate revision by the same user not shown)
Line 1,388:
 
=={{header|langur}}==
Langur uses semi-integreted regex. The following examples use re2 regex literals.
 
There are several functions that can be used with regexes, such as match(), replace(), split(), etc. They can also be matched inusing athe givenforward expressionoperator test(->).
 
To match a string, ...
<syntaxhighlight lang="langur">if matching("somestring" -> re/abc/, "somestring") { ... }</syntaxhighlight>
 
Or...
{{works with|langur|0.10}}
<syntaxhighlight lang="langur">if val .x, .y = submatch(re/(abc+).+?(def)/, "somestring") { ... }</syntaxhighlight>
 
Prior to 0.10, multi-variable declaration/assignment would use parentheses around variable names and values.
<syntaxhighlight lang="langur">if val (.x, .y) = submatch(re/(abc+).+?(def)/, "somestring") { ... }</syntaxhighlight>
 
Or...
<syntaxhighlight lang="langur">givenswitch "somestring" {
case -> re/abc/: ...
...
}</syntaxhighlight>
 
Or...
<syntaxhighlight lang="langur">givenswitch -> re/abc/ {
case "somestring": ...
...
890

edits