Zymba Documentation
Regex
Text
object @Regex() {
count(string $string, string $pattern, int $offset): int {}
escape(string $string, string $delimiter): string {}
isValidPattern(string $pattern): bool {}
match(string $string, string $pattern, int $offset): object {}
matchAll(string $string, string $pattern, int $offset): object {}
replace(string $string, string $pattern, string $replacement, int $limit): string {}
replaceMultiple(string $string, object $replacements): string {}
split(string $string, string $pattern, int $limit): object {}
splitNonEmpty(string $string, string $pattern, int $limit): object {}
substitute(string $string, string $pattern, function $callback, ?object $bind, int $limit): string {}
test(string $string, string $pattern, int $offset): bool {}
}
Static regular expression functions.
Functions
Returns all matches of a global regular expression search of a string against a specific pattern.
CODE
@Regex.matchAll(string $string, string $pattern, int $offset): object
Parameters
| Name | Type | Value | Default |
|---|---|---|---|
| string | string | "" | |
| pattern | string | "" | |
| offset | int | 0 |
Returns
| Type | Value |
|---|---|
object | [[pattern-match, subpattern-match, ...], ...] |
null |
Replaces all matches of a global regular expression search of a string against a specific pattern with a specific replacement.
CODE
@Regex.replace(string $string, string $pattern, string $replacement, int $limit): string
Parameters
| Name | Type | Value | Default |
|---|---|---|---|
| string | string | "" | |
| pattern | string | "" | |
| replacement | string | "" | |
| limit | int | 0 |
Returns
| Type | Value |
|---|---|
string |
Splits a string into isolated substrings on boundaries formed by a specific pattern, whereas empty substrings are discarded.
CODE
@Regex.splitNonEmpty(string $string, string $pattern, int $limit): object
Parameters
| Name | Type | Value | Default |
|---|---|---|---|
| string | string | "" | |
| pattern | string | "" | |
| limit | int | 0 |
Returns
| Type | Value |
|---|---|
object | [substring, ...] |
Substitutes all matches of a global regular expression search of a string against a specific pattern with individual replacements provided by a specific callback function.
CODE
@Regex.substitute(string $string, string $pattern, function $callback, ?object $bind, int $limit): string
Parameters
| Name | Type | Value | Default |
|---|---|---|---|
| string | string | "" | |
| pattern | string | "" | |
| callback | function | null | |
| bind | ?object | null | |
| limit | int | 0 |
Returns
| Type | Value |
|---|---|
string |