Skip to content
FutureBlitz

    Install

    Import std.text.regex

    String

    std.text.regex

    extend

    Extend String

    Regular expressions on a String: whether one matches, and replacing and splitting by one.

    std/text/regex.fb, line 542

    • @PanicsAtCaller Public Method Matches(pattern: String): Bool Throws RegexError method #

      Whether pattern matches somewhere in it, as Regex(pattern).IsMatch does. Its compiled pattern is kept for a while, so calling it again with the same one doesn't compile it again.

    • @PanicsAtCaller Public Method ReplaceAll(pattern: String, replacement: String): String Throws RegexError method #

      A copy with each match of pattern replaced by replacement, as Regex(pattern).Replace does.

    • @PanicsAtCaller Public Method SplitBy(pattern: String): String[] Throws RegexError method #

      The parts between each match of pattern, as Regex(pattern).Split gives them.

      Examples

      Expect((Try "a1b22c".SplitBy(r"\d+")) == ["a", "b", "c"])
      Expect(Try "hello".Matches(r"^h.*o$"))

    Report an issue with this page or with FutureBlitz on GitHub.