std/text/regex▲toc

Regular expressions.

The regular expressions conform to the regular expressions of JavaScript as described at https://​developer.​mozilla.​org/​en-​US/​docs/​Web/​JavaScript/​Guide/​Regular_​Expressions.

type regexstd/text/regex/regex: V

Abstract type of a regular expression object.

Find a match for a regular expression. See also find and contains.

Match a regular expression regexstd/text/regex/regex: (regex : string, ignorecase : ? bool, multiline : ? bool) -> regex over a string s. Matches at most atmost times (and matches all by default). Returns always an odd number of elements where every even element is a match and the odd ones the string parts between the matches. See also find-allstd/text/regex/find-all: (s : string, r : regex, atmost : ? int) -> list<string> and strings.

How many groups are captured by this regex?

Create a new regular expression. Takes two optional parameters. Set ignoreCase to Truestd/core/types/True: bool to ignore uppercase/lowercase distinction. If multiline is set to Truestd/core/types/True: bool, then ^ and $ match also the beginning and end of every line (instead of the entire input).

Return the pattern as a string.

fun string/replace( s : stringstd/core/types/string: V, regex : regexstd/text/regex/regex: V, repl : stringstd/core/types/string: V ) : stringstd/core/types/string: V

Replace the first occurrence of regexstd/text/regex/regex: (regex : string, ignorecase : ? bool, multiline : ? bool) -> regex with a replacement string repl in a string s. The replacement string can contain $$ for a $ sign, $n for a capture group, $& for the entire match ==$0.

fun string/replace-all( s : stringstd/core/types/string: V, regex : regexstd/text/regex/regex: V, repl : stringstd/core/types/string: V, atmost : ? intstd/core/types/int: V ) : stringstd/core/types/string: V

Replace all occurrences of regexstd/text/regex/regex: (regex : string, ignorecase : ? bool, multiline : ? bool) -> regex with the replacement string repl in a string s. The replacement string can contain $$ for a $ sign, $n for a capture group, $& for the entire match ==$0.

fun captured( matched : liststd/core/types/list: V -> V<sslicestd/core/sslice/sslice: V> ) : stringstd/core/types/string: V

Return the full matched string of a capture group.

fun captures( xs : liststd/core/types/list: V -> V<liststd/core/types/list: V -> V<sslicestd/core/sslice/sslice: V>> ) : liststd/core/types/list: V -> V<stringstd/core/types/string: V>

Return the full matched string part for a list of matched capture groups.

fun contains( s : stringstd/core/types/string: V, r : regexstd/text/regex/regex: V ) : boolstd/core/types/bool: V

Does a regular expression pattern occur in a string s? (note: called test in javascript).

fun find( s : stringstd/core/types/string: V, r : regexstd/text/regex/regex: V ) : maybestd/core/types/maybe: V -> V<stringstd/core/types/string: V>

Find a match for a regular expression. See also execstd/text/regex/exec: (regex : regex, s : string) -> list<sslice>.

fun find-all( s : stringstd/core/types/string: V, r : regexstd/text/regex/regex: V, atmost : ? intstd/core/types/int: V ) : liststd/core/types/list: V -> V<stringstd/core/types/string: V>

Find all matches for a regular expression in a string.

fun matched( s : sslicestd/core/sslice/sslice: V ) : boolstd/core/types/bool: V

Check if a capture group was matched.

fun replace( s : stringstd/core/types/string: V, r : regexstd/text/regex/regex: V, repl : (liststd/core/types/list: V -> V<sslicestd/core/sslice/sslice: V>) -> e stringstd/core/types/string: V ) : e stringstd/core/types/string: V

Replace the first occurrence of regexstd/text/regex/regex: (regex : string, ignorecase : ? bool, multiline : ? bool) -> regex by the result of the replacement fun repl in a string s.

fun replace-all( s : stringstd/core/types/string: V, r : regexstd/text/regex/regex: V, repl : (liststd/core/types/list: V -> V<sslicestd/core/sslice/sslice: V>) -> e stringstd/core/types/string: V, atmost : ? intstd/core/types/int: V ) : e stringstd/core/types/string: V

Replace the all occurrences of regexstd/text/regex/regex: (regex : string, ignorecase : ? bool, multiline : ? bool) -> regex by the result of the replacement fun repl in a string s.

fun split( s : stringstd/core/types/string: V, r : regexstd/text/regex/regex: V, atmost : ? intstd/core/types/int: V ) : liststd/core/types/list: V -> V<stringstd/core/types/string: V>

Split a string s in at most atmost parts using a regular expression r as separator.

fun testabc( s : stringstd/core/types/string: V ) : boolstd/core/types/bool: V
private import std/core/typesstd/core/types, std/core/hndstd/core/hnd, std/core/exnstd/core/exn, std/core/boolstd/core/bool, std/core/orderstd/core/order, std/core/charstd/core/char, std/core/intstd/core/int, std/core/vectorstd/core/vector, std/core/stringstd/core/string, std/core/sslicestd/core/sslice, std/core/liststd/core/list, std/core/maybestd/core/maybe, std/core/eitherstd/core/either, std/core/tuplestd/core/tuple, std/core/showstd/core/show, std/core/debugstd/core/debug, std/core/delayedstd/core/delayed, std/core/consolestd/core/console, std/corestd/core, std/num/int32std/num/int32