RegularExpression
in package
Class RegularExpression
Tags
Table of Contents
Constants
- VALIDATION_REGEX = '([^a-zA-Z0-9\\\\x00])[^\1]+\1(?:[^\1]+\1)?[ixAUJ]*'
- VALID_FLAGS = [ 'i', // PCRE_CASELESS 'x', // PCRE_EXTENDED 'A', // PCRE_ANCHORED 'U', // PCRE_UNGREEDY 'J', ]
Properties
- $delimiter : string
- Delimiter
- $flags : array<string|int, mixed>
- Flags
- $hasReplacement : bool
- Wheter this regex has a replacement or not
- $regex : string
- Regex
- $replacement : string
- Replacement string
Methods
- __construct() : mixed
- Contructor for RegularExpression
- __toString() : string
- Return the regular expression concatenated by delimiter
- getDelimiter() : string
- Getter for Delimiter
- getFlags() : array<string|int, mixed>
- Getter for flags
- getRegex() : string
- Getter for $regex
- getReplacement() : string
- Getter for $replacement
- match() : bool
- Match the input string with regular expression
- removeReplacement() : mixed
- Removes the replacement part.
- replace() : string
- Search and replace in the Input string
- setDelimiter() : mixed
- Set the delimiter
- setFlags() : mixed
- Set the flags
- setRegex() : mixed
- Set the regular expression
- setReplacement() : mixed
- Set the replacement string
Constants
VALIDATION_REGEX
public
mixed
VALIDATION_REGEX
= '([^a-zA-Z0-9\\\\x00])[^\1]+\1(?:[^\1]+\1)?[ixAUJ]*'
VALID_FLAGS
protected
mixed
VALID_FLAGS
= [
'i',
// PCRE_CASELESS
'x',
// PCRE_EXTENDED
'A',
// PCRE_ANCHORED
'U',
// PCRE_UNGREEDY
'J',
]
Properties
$delimiter
Delimiter
protected
string
$delimiter
= '/'
$flags
Flags
protected
array<string|int, mixed>
$flags
= array()
$hasReplacement
Wheter this regex has a replacement or not
protected
bool
$hasReplacement
= false
$regex
Regex
protected
string
$regex
= ''
$replacement
Replacement string
protected
string
$replacement
Methods
__construct()
Contructor for RegularExpression
public
__construct([string $regex = '' ]) : mixed
Parameters
- $regex : string = ''
-
Regular expression
__toString()
Return the regular expression concatenated by delimiter
public
__toString() : string
Return values
string —Return the regular expression concatenated by delimiter
getDelimiter()
Getter for Delimiter
public
getDelimiter() : string
Return values
stringgetFlags()
Getter for flags
public
getFlags() : array<string|int, mixed>
Return values
array<string|int, mixed>getRegex()
Getter for $regex
public
getRegex() : string
Return values
stringgetReplacement()
Getter for $replacement
public
getReplacement() : string
Return values
stringmatch()
Match the input string with regular expression
public
match(string $input) : bool
Parameters
- $input : string
-
Input string
Return values
bool —True|False True on regular expression matches the string
removeReplacement()
Removes the replacement part.
public
removeReplacement() : mixed
replace()
Search and replace in the Input string
public
replace(string $input) : string
Parameters
- $input : string
-
Input string
Return values
string —Replaced string
setDelimiter()
Set the delimiter
public
setDelimiter(string $delimiter) : mixed
Parameters
- $delimiter : string
setFlags()
Set the flags
public
setFlags(array<string|int, mixed> $flags) : mixed
Parameters
- $flags : array<string|int, mixed>
setRegex()
Set the regular expression
public
setRegex(string $regex) : mixed
Parameters
- $regex : string
setReplacement()
Set the replacement string
public
setReplacement(string $replacement) : mixed
This forces a replacement, also if $replacement is an empty string. To remove the replacement part, use RegularExpression::removeReplacement().
Parameters
- $replacement : string