Regex Library



( ZN >= 1.0.0 )

We aimed to make regular expressions fit to a certain standard and make meaningful by expressing complex and meaningless symbols with words. We do not think that this library is a necessity to use, but we think that it will help some who are strangers to the concept of regular expressions.

 

# Custom Cycles

The following table shows how the pattern parameters in regular expressions change in the ZN Regex library.

Expression Original Expression meaning Sample
{Nonword} W + Characters that are not numbers, letters, and underscores . * - + =)
{WORD} w + Characters with numbers, letters, and hyphens. a9_
{Nonnumeric} D The figures are not characters. a #
{numeric} | {num} D A number from 0 to 9 3
{specialChar} | {scheme is} W  A single character without numbers, letters, and underscores +!
{nonSpecialChar} | {} the nonsch w A single character with a number, letter, and hyphen. a
{Alpha} [A-zA-Z]+ A single character with only letters. to
{Forehead} [A-zA-Z0-9]+ A single character with only letters or numbers. 9
{Number} [0-9]+ A single character with only a number. 5
{char} | {any} . Any character. $
Nonspa by {} S Non- space character. b
{Space} s Character with space. \s
{starting} | {start} ^ Starting with. ^ a
{ending} | {end} $ Ending with. a $
{repeatZ} | {iterate} * Zero or more times. a *
{Repeat} + At least one or more a +
Whether {} ? It becomes a character or not. a?
{O} | Or. a | b
{Eol} \ R \ n End of line.  
{Tab} \ t Tab.  
{Incense} I It ignores case sensitivity.  
{Generic} g It does not stop at the first pairing, it makes extensive scans.  
Each {} s Makes the dot character, which represents everything but the beginning of a line,  
{Multiline} m The ^ and $ characters allow each line to represent leading and trailing.  
{Inspace} x Ignores whitespace characters.  

You can use the following configuration file to add your own custom expression to the list.

File:  Settings / Expressions.php -> regex
Note : You do not need to use the slash (\) sign at the beginning to use some special characters as normal characters when writing patterns . Exception is only parentheses groups and (-) hyphen. .

 

# Methods


Array match ( String $ pattern , String $ data , String $ ex = NULL , String $ del = '/' )
Array matchAll ( String $ pattern , String $ data , String $ ex = NULL , String $ del = '/' )
String replace ( String $ pattern , String $ rep , String $ data , String $ ex = NULL , String $ del = '/' )
String quote ( String $ data , String $ delimiter = NULL )
String to ( String $ data )
String group ( String $ data )
String recount ( String $ data )

 

# Match ( ZN >= 1.0.0 )


PHP preg_match () and preg_match_all () functions are arranged and arranged in a certain standard.

Parameters

String $ pattern The pattern to match the verb.
String $ data Data.
String $ extrachars Extra character control of regular expressions.
String $ delimiter = '/' Regular expressions pattern separator.
return Array

Use of

$data    = 'https://www.znframework.com';
$pattern = '{char}{repeatZ}://w{repeat}.{char}{repeatZ}.com';
$result  = Regex::match($pattern, $data);

output($result);
0 => string 'https://www.znframework.com' (length = 28 )

Note that if used above / or . are not marked as special characters, but are treated as normal characters .

 

# Replace ( ZN >= 1.0.0 )


PHP preg_replace () function is arranged and arranged in a certain standard.

Parameters

String $ pattern The pattern to match the verb.
String $ Replace The expression with which the matches are to be replaced.
String $ data Data.
String $ extrachars Extra character control of regular expressions.
String $ delimiter = '/' Regular expressions pattern separator.
return String

Use of

$data    = 'https://www.znframework.com';
$replace = 'www.';
$result  = Regex::replace($replace, '', $data);

echo $result;
I https://znframework.co 

 

# Quote ( ZN> = 2.0.0 )

This method preg_quote()is the same as the use of the method.

Use of

echo Regex::quote('Hello$user');
Hello | $ user