Regular expressions: Difference between revisions

added langur language example
m (→‎{{header|NewLISP }}: fix header markup)
(added langur language example)
Line 1,081:
`I am the replacement string` replaces `original` with `replacement`
</pre>
 
=={{header|Langur}}==
Langur uses semi-integreted regex. An re2 literal without interpreting langur escape codes uses RE// and with langur escape codes interpreted uses re//. Langur escape codes, when applicable, are interpreted before a string is sent to the regex compiler.
 
There are several functions that can be used with regex literals (and some of them with plain strings), such as match(), replace(), split(), etc.
 
Progressive matching (a.k.a. "global") is done with split() and replace() and the functions that use the plural form, such as matches(), indices(), etc. These will return an array or array of arrays. Progressive matching can be limited by passing a maximum.
 
Regex functions that return an array will return an empty array for no match. The matching() function returns a Boolean. The match() function returns a string (or null for no match).
 
To match a string, ...
<lang Langur>if matching(re/abc/, "somestring") { ... }</lang>
 
Or...
<lang Langur>if val (.x, .y) = submatch(re/(abc+).+?/, "somestring") { ... }</lang>
 
Substitution does not alter the original string.
<lang Langur>replace("abcdef", re/abc/, "Y")
# result: "Ydef"</lang>
 
=={{header|Lasso}}==
890

edits