std:regex リファレンス
@import 'std:regex' で取得する正規表現モジュール。パターンのコンパイル (compile) と、マッチ・抽出・置換・分割を持つ Regex object を提供する (RE2 構文・線形時間)。
compile
compile(pattern)
compile: { String | Result(Regex) }
パターン文字列をコンパイルし Result (成功時 Ok(Regex object)) を返す。
escape
escape(s)
escape: { String | String }
正規表現メタ文字をすべてエスケープしたリテラル一致のパターン断片を返す。
>>> regex.escape("1+1=2") "1\\+1=2"
Regex メソッド
captures
re.captures(text) captures: { String | Option(List(Option(String))) }
最左一致のグループ列 (添字 = グループ番号、0 は全体一致) を Option で返す。
find
re.find(text) find: { String | Option(String) }
最左の一致文字列を Option で返す (一致なしは None)。
find_all
re.find_all(text) find_all: { String | List(String) }
重ならない全一致文字列を List で返す (一致なしは [])。
replace
re.replace(text, repl) replace: { String, String | String }
全一致をテンプレート repl ($1 等でグループ参照) で置換した String を返す。
split
re.split(text) split: { String | List(String) }
一致を区切りとして text を分割した List を返す (空要素も保持)。
test
re.test(text) test: { String | Bool }
text 中に一致があるか Bool を返す。