- 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 patternStringfor the specifiedRegex ::quoteReplacement()- Returns a literal replacementStringfor 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): RegexCreates a new Regex of regex with $string and $flag
Regex::match(string $pattern, string $string, int|string $flags): boolTells whether or not this string matches the given regular expression. See also java.lang.String.matches()
Regex::split(string $pattern, string $string, int $limit): arraySplits this string around matches of the given regular expression. See also java.lang.String.split()
Regex::quote(string $string): stringReturns 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): stringReturns 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): voidRegex of $pattern and $flag
getPattern(): stringGet the current pattern.
getInput(): stringGet the input string.
getFlags(): intGet the current flags
test(string $string): boolExecutes a search for a match between a regular expression and a specified string. Returns true or false.
matches(): boolAttempts to match the entire region against the pattern.
all(int $start): arrayReturns array of all found groups.
one(int $start): array|nullCalls find() + groups() methods and returns the result of the groups() method. Returns the first found groups, if founds nothing returns null.
first(int $start): arrayAlias of one() method.
last(int $start): arrayFinds the last match and returns last groups.
find(int|null $start): boolResets 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): stringReplaces 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): stringReplaces the first subsequence of the input sequence that matches the pattern with the given replacement string.
replaceGroup(int $group, string $replacement): stringreplaceWithCallback(callable $callback): stringwith(string $string): RegexDuplicates this pattern with a new $string
withFlags(int|string $flags): RegexClone this object with the new $flags
groups(): arrayReturns an array of all group.
group(null|int $group): stringReturns the input subsequence captured by the given group during the previous match operation.
groupNames(): arrayReturns group names.
getGroupCount(): intReturns the number of capturing groups in this matcher's pattern.
start(null|int $group): intReturns the start index of the previous match.
end(null|int $group): intReturns the offset after the last character matched.
hitEnd(): boolReturns true if the end of input was hit by the search engine in the last match operation performed by this matcher.
requireEnd(): boolReturns 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(): boolAttempts to match the input sequence, starting at the beginning of the region, against the pattern.
region(int $start, int $end): RegexSets 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(): intReports 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(): intReports 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): $thisResets 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|stringnext(): voidkey(): intvalid(): boolrewind(): void__clone(): voidClass is immutable, the disallowed clone method