(1) Ereg,eregi
This is a regular expression matching function, the former is case-insensitive, and the latter is irrelevant.
Usage:
Ereg (regular expression, string, [match part array name]);
Regular expressions in PHP3.0 are generally similar to those used in grep.
(2) Ereg_replace,eregi_replace
These are replacement functions.
Usage:
Ereg_replace (Regular expression, substitution string, original string);
A strtr in the string handler is a "translation" function, similar to the tr/.../.../in Perl,
Usage:
STRTR (String, "from", "to");
For example:
STRTR ("Aaabb", "AB", "CD") returns to "CCCDD".
(3) Split
It's similar to the explode function, but this time you can split the string at a place that matches a regular expression.
Usage:
Split (regular expression, string, [number of items taken out before]);
These functions use a regular string as the first argument. PHP uses the extended regular string defined by the POSIX 1003.2 standard. To examine the full description of POSIX regular expressions see the man page under the Regex directory in the PHP package.
Example 2-4. Regular expression Examples
Ereg ("abc", $string);
/* Returns true if "abc" is found anywhere in $string. */
Ereg ("^abc", $string);
/* Returns true if "abc" is found at the beginning of $string. */
Ereg ("abc$", $string);
/* Returns true if "abc" is found in the end of $string. */
Eregi ("(ozilla.[ 23]| MSIE.3) ", $HTTP _user_agent);
/* Returns True if client browser is Netscape 2, 3 or MSIE 3. */
Ereg ([: alnum:]]+) ([[: alnum:]]+) ([[: alnum:]]+), $string, $regs);
/* Places Three space separated words into $regs [1], $regs [2] and $regs [3]. */
Ereg_replace ("^", "
", $string);
* Put a
Tag at the beginning of $string. */
Ereg_replace ("$", "
", $string);
* Put a
Tag at the end of $string. */
Ereg_replace ("\ n", "", $string);
/* Get rid of any carriage return characters in $string. */
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.