regex

Generated by tinox doc

tinox.core.regex, bundled with the compiler and also available as a standalone tinox-central package.

Basic matching

import tinox.core.regex
class Main
{
    fnc main() -> Int32
    {
        const text: String = "order #4711 shipped, order #4899 pending"
        if (Regex::isMatch("order #[0-9]+", text))
        {
            println("found at least one order reference")
        }

        const first: String = Regex::findFirst("#[0-9]+", text)
        println("first match: " + first)
        const all: List<String> = Regex::findAll("#[0-9]+", text)
        var i: Int64 = 0
        while i < all.len()
        {
            println("match " + i.toString() + ": " + all[i])
            i = i + 1
        }

        const redacted: String = Regex::replaceAll("#[0-9]+", text, "#***")
        println(redacted)
        return 0
    }
}

fn tinoxRegexPatternError(pattern: String, icase: Int64) → String

fn tinoxRegexIsMatch(pattern: String, text: String, icase: Int64) → Int64

fn tinoxRegexFindFirst(pattern: String, text: String, icase: Int64) → String

fn tinoxRegexFindAll(pattern: String, text: String, icase: Int64) → List<String>

fn tinoxRegexReplaceAll(pattern: String, text: String, replacement: String, icase: Int64) → String

fn tinoxRegexSplit(pattern: String, text: String, icase: Int64) → List<String>

class Regex

* POSIX extended regular expressions with Tinox's Perl character-class * translation. Invalid patterns throw RegexError errors. WithOptions methods * accept ignoreCase; existing methods remain case-sensitive. Validation * compiles the pattern once before execution compiles it again.

Methods

fn isValid(pattern: String) → Bool
fn isValidWithOptions(pattern: String, ignoreCase: Bool) → Bool
@Throwsfn checkedFlags(pattern: String, ignoreCase: Bool) → Int64
@Throwsfn isMatch(pattern: String, text: String) → Bool
@Throwsfn isMatchWithOptions(pattern: String, text: String, ignoreCase: Bool) → Bool
@Throwsfn findFirst(pattern: String, text: String) → String
@Throwsfn findFirstWithOptions(pattern: String, text: String, ignoreCase: Bool) → String
@Throwsfn findAll(pattern: String, text: String) → List<String>
@Throwsfn findAllWithOptions(pattern: String, text: String, ignoreCase: Bool) → List<String>
@Throwsfn replaceAll(pattern: String, text: String, replacement: String) → String
@Throwsfn replaceAllWithOptions(pattern: String, text: String, replacement: String, ignoreCase: Bool) → String
@Throwsfn split(pattern: String, text: String) → List<String>
@Throwsfn splitWithOptions(pattern: String, text: String, ignoreCase: Bool) → List<String>

@Errorclass RegexError

* Invalid regular expression.

Fields

messageString