std/regex▲toc

This module supports JavaScriptStyle regular expressions.

The regular expressions conform to the regular expressions of JavaScript as described at https://developer.mozilla.org/enUS/docs/JavaScript/Guide/Regular_Expressions

struct matchedstd/regex/matched: V(index : intstd/core/int: Vmatched : stringstd/core/string: Vgroups : vectorstd/core/vector: V -> V<stringstd/core/string: V>)

The result of a regular expression match, where indexstd/regex/index: (matched : matched) -> int is the index in the original source string where the match begins, matched is the content that was matched, and groupsstd/regex/groups: (matched : matched) -> vector<string> is a vector that contains the content for each capture groups (where groups[0] == matched).

Automatically generated. Retrieves the groups constructor field of the matchedstd/regex/matched: V type.

Automatically generated. Retrieves the index constructor field of the matchedstd/regex/matched: V type.

Automatically generated. Retrieves the matched constructor field of the matchedstd/regex/matched: V type.

type regexstd/regex/regex: V

Abstract type of a regular expression object

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

fun contains( s : stringstd/core/string: V, r : regexstd/regex/regex: V, start : ?intstd/core/int: V ) : boolstd/core/bool: V

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

fun find( s : stringstd/core/string: V, regex : regexstd/regex/regex: V, start : ?intstd/core/int: V ) : maybestd/core/maybe: V -> V<matchedstd/regex/matched: V>

Find a match for a regular expression starting at start position start (by default 0). See also contains (note: this function is called |exec| in JavaScript).

fun findAll( s : stringstd/core/string: V, regex : regexstd/regex/regex: V, start : ?intstd/core/int: V ) : vectorstd/core/vector: V -> V<matchedstd/regex/matched: V>

Find all matches for a regular expression in a string.

fun replace( s : stringstd/core/string: V, regex : regexstd/regex/regex: V, repl : (matched : matchedstd/regex/matched: V) -> e stringstd/core/string: V, start : ?intstd/core/int: V ) : e stringstd/core/string: V

Replace the first occurrence of regex by the result of the replacement function repl in a string s.

fun replace( s : stringstd/core/string: V, regex : regexstd/regex/regex: V, repl : stringstd/core/string: V, start : ?intstd/core/int: V ) : stringstd/core/string: V

Replace the first occurrence of regex by the result 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 replaceAll( s : stringstd/core/string: V, regex : regexstd/regex/regex: V, repl : (matched : matchedstd/regex/matched: V) -> e stringstd/core/string: V, start : ?intstd/core/int: V ) : e stringstd/core/string: V

Replace the all occurrences of regex by the result of the replacement function repl in a string s.

fun replaceAll( s : stringstd/core/string: V, regex : regexstd/regex/regex: V, repl : stringstd/core/string: V, start : ?intstd/core/int: V ) : stringstd/core/string: V

Replace all ocurrences of regex by the result of a replacement string repl in a string s.

fun split( s : stringstd/core/string: V, r : regexstd/regex/regex: V, n : ?intstd/core/int: V, start : ?intstd/core/int: V ) : vectorstd/core/vector: V -> V<stringstd/core/string: V>

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