With regard to regular expressions (Regular Expression_r), it seems to be translated into: string parsing is more literal meaning. But at present all the related books are translated into regular expressions or formal representations .... And so on, is actually responsible for string resolution alignment, and for strings to do related processing.
Ereg: string alignment parsing.
Ereg_replace: The string is parsed and replaced.
Eregi: string alignment parsing, regardless of case.
Eregi_replace: String comparison resolution and substitution, regardless of case.
Split: Cuts the string according to a specified rule.
Sql_regcase: Returns uppercase and lowercase characters verbatim from a string. Ereg
string alignment parsing.
Syntax: bool Ereg (string pattern, string string, array [regs]);
Return Value: Boolean value
Function type: Data processing
This function resolves string strings using pattern rules. The value returned by the result is placed in the array parameter regs, Regs[0] content is the original string string, Regs[1] is the first regular string, regs[2] is the second rule string, and so on. If the argument regs is omitted, the return value is true only if it is simply compared.
This example is markus@dnet.it in 14-jun-1999, the user input of the e-mail can be a simple check, check whether the user's e-mail string has the @ character, in front of the @ character has English letters or numbers, after a few sections string, after the last decimal point Can only have two or three English letters. Super@mail.wilson.gs can pass the examination, Super@mail.wilson cannot pass the examination.
<?php
if (Eregi (^[_\.0-9a-z-]+@) ([0-9a-z][0-9a-z-]+\.) +[a-z]{2,3}$ ", $email)) {
echo "Your e-mail through preliminary check";
}
?>
ereg_replace
String pairs are parsed and replaced.
Syntax: string ereg_replace (string pattern, string replacement, string string);
return value: String
Function type: Data processing
This function resolves the string string with the rule of pattern, and replacement the strings to be replaced by parameters. The return value is a string type, and the result of the string is replaced.
Ken@freebsdrocks.com The example presented in 16-mar-1999.
<?php
$text = ' is ' a {1} day, not {2} and {3}. '
$daytype = Array (1 => ' fine '),
2 => ' Overcast ',
3 => ' rainy ');
while (Ereg ([0-9]+)} ', $text, $regs)) {
$found = $regs [1];
$text = ereg_replace ("\{". $found. " \} ", $daytype [$found], $text);
}
echo "$text \ n";
This is a fine day, not overcast and rainy.
?>
Ken@freebsdrocks.com also provides examples of Perl programs with the same functionality as the following:
$text = ' is ' a {1} day, not {2} and {3}. '
%daytype = (1 => ' fine ',
2 => ' Overcast ',
3 => ' rainy ');
$text =~ s/{(\d+)}/$daytype {$1}/eg;
print "$text \ n";
The result is: ' It's a fine day, not overcast and rainy.
Eregi
String alignment parsing, regardless of case.
Syntax: int eregi (string pattern, string string, array [regs]);
return value: Integer/array
Function type: Data processing
This function is similar to Ereg () and uses the same. The difference is that ereg () is case-sensitive and this function has nothing to do with case. Eregi_replace
String pairs are parsed and superseded, regardless of case.
Syntax: string eregi_replace (string pattern, string replacement, string string);
return value: String
Function type: Data processing
This function is similar to ereg_replace () and uses the same. The difference is that ereg_replace () is case-sensitive and this function has nothing to do with case.
Split
Cuts the string according to a specified rule.
Syntax: array Split (string pattern, string string, int [limit]);
return value: Array
Function type: Data processing
This function separates strings according to the rules you specify. The returned value after the incision is an array variable. The parameter pattern is the specified rule string, the parameter string is the string to be processed, and the parameter limit can be omitted, indicating that the most desirable value is to be processed. It is noteworthy that the pattern parameters of this function are case-sensitive. Sql_regcase
Returns the string literal to uppercase and lowercase characters.
Syntax: string Sql_regcase (String string);
return value: Array
Function type: Data processing
This function returns the character of a string verbatim to case. This function has no effect on PHP usage, but may provide external programs or database processing.
The return string in the example is [WW][II][LL][SS][OO][NN]
<?php
Print (Sql_regcase ("Wilson"));
?>