- class
Regex
(php\util\Regex
) - package
std
- source
php/util/Regex.php
Description
http://www.regular-expressions.info/java.html
Class Regex, Immutable
Regex ::
of()
- Creates a new Regex of regex with $string and $flagRegex ::
match()
- Tells whether or not this string matches the given regular expression.Regex ::
split()
- Splits this string around matches of the given regular expression.Regex ::
quote()
- Returns a literal patternString
for the specifiedRegex ::
quoteReplacement()
- Returns a literal replacementString
for the specified
->
__construct()
- Regex of $pattern and $flag->
getPattern()
- Get the current pattern.->
getInput()
- Get the input string.->
getFlags()
- Get the current flags->
test()
- Executes a search for a match between a regular expression and a specified string. Returns true or false.->
matches()
- Attempts to match the entire region against the pattern.->
all()
- Returns array of all found groups.->
one()
- Calls find() + groups() methods and returns the result of the groups() method.->
first()
- Alias of one() method.->
last()
- Finds the last match and returns last groups.->
find()
- Resets this matcher and then attempts to find the next subsequence of->
replace()
- Replaces every subsequence of the input sequence that matches the->
replaceFirst()
- Replaces the first subsequence of the input sequence that matches the->
replaceGroup()
->
replaceWithCallback()
->
with()
- Duplicates this pattern with a new $string->
withFlags()
- Clone this object with the new $flags->
groups()
- Returns an array of all group.->
group()
- Returns the input subsequence captured by the given group during the->
groupNames()
- Returns group names.->
getGroupCount()
- Returns the number of capturing groups in this matcher's pattern.->
start()
- Returns the start index of the previous match.->
end()
- Returns the offset after the last character matched.->
hitEnd()
- Returns true if the end of input was hit by the search engine in->
requireEnd()
- Returns true if more input could change a positive match into a->
lookingAt()
- Attempts to match the input sequence, starting at the beginning of the->
region()
- Sets the limits of this matcher's region. The region is the part of the->
regionStart()
- Reports the start index of this matcher's region. The->
regionEnd()
- Reports the end index (exclusive) of this matcher's region.->
reset()
- Resets this matcher.->
current()
->
next()
->
key()
->
valid()
->
rewind()
->
__clone()
- Class is immutable, the disallowed clone method
Regex::of(string $pattern, int|string $flag, string $string): Regex
Creates a new Regex of regex with $string and $flag
Regex::match(string $pattern, string $string, int|string $flags): bool
Tells whether or not this string matches the given regular expression. See also java.lang.String.matches()
Regex::split(string $pattern, string $string, int $limit): array
Splits this string around matches of the given regular expression. See also java.lang.String.split()
Regex::quote(string $string): string
Returns a literal pattern String
for the specified
String
.
This method produces a String
that can be used to
create a Regex
that would match the string
$string
as if it were a literal pattern. Metacharacters
or escape sequences in the input sequence will be given no special
meaning.
Regex::quoteReplacement(string $string): string
Returns a literal replacement String
for the specified
String
.
This method produces a String
that will work
as a literal replacement $string in the
replaceWithCallback() method of the php\util\Regex
class.
The String
produced will match the sequence of characters
in $string treated as a literal sequence. Slashes ('') and
dollar signs ('$') will be given no special meaning.
__construct(string $pattern, int|string $flag, string $string): void
Regex of $pattern and $flag
getPattern(): string
Get the current pattern.
getInput(): string
Get the input string.
getFlags(): int
Get the current flags
test(string $string): bool
Executes a search for a match between a regular expression and a specified string. Returns true or false.
matches(): bool
Attempts to match the entire region against the pattern.
all(int $start): array
Returns array of all found groups.
one(int $start): array|null
Calls find() + groups() methods and returns the result of the groups() method. Returns the first found groups, if founds nothing returns null.
first(int $start): array
Alias of one() method.
last(int $start): array
Finds the last match and returns last groups.
find(int|null $start): bool
Resets this matcher and then attempts to find the next subsequence of the input sequence that matches the pattern, starting at the specified index.
replace(string $replacement): string
Replaces every subsequence of the input sequence that matches the pattern with the given replacement string.
This method first resets this matcher. It then scans the input sequence looking for matches of the pattern. Characters that are not part of any match are appended directly to the result string; each match is replaced in the result by the replacement string.
replaceFirst(string $replacement): string
Replaces the first subsequence of the input sequence that matches the pattern with the given replacement string.
replaceGroup(int $group, string $replacement): string
replaceWithCallback(callable $callback): string
with(string $string): Regex
Duplicates this pattern with a new $string
withFlags(int|string $flags): Regex
Clone this object with the new $flags
groups(): array
Returns an array of all group.
group(null|int $group): string
Returns the input subsequence captured by the given group during the previous match operation.
groupNames(): array
Returns group names.
getGroupCount(): int
Returns the number of capturing groups in this matcher's pattern.
start(null|int $group): int
Returns the start index of the previous match.
end(null|int $group): int
Returns the offset after the last character matched.
hitEnd(): bool
Returns true if the end of input was hit by the search engine in the last match operation performed by this matcher.
requireEnd(): bool
Returns true if more input could change a positive match into a negative one.
If this method returns true, and a match was found, then more input could cause the match to be lost. If this method returns false and a match was found, then more input might change the match but the match won't be lost. If a match was not found, then requireEnd has no meaning.
lookingAt(): bool
Attempts to match the input sequence, starting at the beginning of the region, against the pattern.
region(int $start, int $end): Regex
Sets the limits of this matcher's region. The region is the part of the input sequence that will be searched to find a match. Invoking this method resets the matcher, and then sets the region to start at the index specified by the $start parameter and end at the index specified by the $end parameter.
regionStart(): int
Reports the start index of this matcher's region. The
searches this matcher conducts are limited to finding matches
within regionStart()
(inclusive) and
regionEnd()
(exclusive).
regionEnd(): int
Reports the end index (exclusive) of this matcher's region.
The searches this matcher conducts are limited to finding matches
within regionStart()
(inclusive) and
regionEnd()
(exclusive).
reset(null|string $string): $this
Resets this matcher.
Resetting a matcher discards all of its explicit state information and sets its append position to zero. The matcher's region is set to the default region, which is its entire character sequence. The anchoring and transparency of this matcher's region boundaries are unaffected.
current(): null|string
next(): void
key(): int
valid(): bool
rewind(): void
__clone(): void
Class is immutable, the disallowed clone method