Pattern
Regular expression pattern matching.
xxml
Language::TextMethods
| Method | Parameters | Returns | Description |
|---|---|---|---|
| Constructor | regex: String^ | Pattern^ | Compile regex pattern |
| matches | input: String^ | Bool^ | Full match check |
| find | input: String^ | Bool^ | Partial match check |
| findAll | input: String^ | List<String>^ | All matches |
| replace | input: String^, replacement: String^ | String^ | Replace all matches |
| split | input: 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"]