Regular expressions: Difference between revisions

Content added Content deleted
Line 1,083: Line 1,083:


=={{header|Langur}}==
=={{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.
Langur uses semi-integreted regex. There are several functions that can be used with regexes, such as match(), replace(), split(), etc.

Interpolated strings or regex literals require a $ sign.
<lang Langur>$"\.x;" # interpolated string
$re/\.x;/ # interpolated regex</lang>

Valid quote mark pairs include the following.
<lang Langur>// '' "" {} [] () <></lang>

There are several functions that can be used with regexes, 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, ...
To match a string, ...