Pattern

Regular expression pattern matching.

xxml
Language::Text

Methods

MethodParametersReturnsDescription
Constructorregex: String^Pattern^Compile regex pattern
matchesinput: String^Bool^Full match check
findinput: String^Bool^Partial match check
findAllinput: String^List<String>^All matches
replaceinput: String^, replacement: String^String^Replace all matches
splitinput: String^List<String>^Split by pattern

Examples

Pattern Matching

xxml
Instantiate Text::Pattern^ As <emailPattern> = Text::Pattern::Constructor(
    String::Constructor("[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}")
);

Instantiate Bool^ As <valid> = emailPattern.matches(String::Constructor("user@example.com"));
// Result: true

Instantiate Text::Pattern^ As <digits> = Text::Pattern::Constructor(String::Constructor("\\d+"));
Instantiate Collections::List<String>^ As <numbers> = digits.findAll(
    String::Constructor("abc123def456")
);
// Result: ["123", "456"]

See Also