std/regex¶
module regex
Text matched against a regular expression. A pattern is a String; one
that does not parse is an evaluation error at the call. The module is
imported where it is used: import regex.
is_match— Whetherpatternmatches somewhere intext:"a1b22c" | regex.is_match("[0-9]+")istrue.find— The first match ofpatternintext, ornone:"a1b22c" | regex.find("[0-9]+")is"1".find_all— Every non-overlapping match ofpatternintext, in order:"a1b22c" | regex.find_all("[0-9]+")is["1", "22"].captures— The first match ofpatternintextand its groups, whole match first, ornone; a group that took no part in the match is"":"a" | regex.captures("(a)|(b)")is["a", "a", ""].replace_all—textwith every match ofpatternreplaced byreplacement, in which$1is the first group:"a1b22c" | regex.replace_all("([0-9]+)", "<$1>")is"a<1>b<22>c".replace_first—textwith the first match ofpatternreplaced byreplacement, in which$1is the first group:"a1b22c" | regex.replace_first("[0-9]+", "#")is"a#b22c".split— The pieces oftextbetween matches ofpattern, in order:"a1b22c" | regex.split("[0-9]+")is["a", "b", "c"].