Analyze the PHP regular expression function library. What is the PHP regular expression function library? Here we will introduce you to the PHP regular expression function library (POSIX extension) greedy Matching. we should note that what is the condition submode and many other analysis PHP regular expression function library? Here we will introduce you to the PHP regular expression function library (POSIX extension) greedy matching, unsupported features in the condition submode and many other POSIX Extended Regular expression syntaxes.
Warning in PHP regular expression function library learning:
This type of regular expression cannot be safely used in binary mode. You can use the PCRE function library. Regular expressions are used in PHP for complex string operations. Functions that support regular expressions are:
◆ Ereg ()
◆ Ereg_replace ()
◆ Eregi ()
◆ Eregi_replace ()
◆ Split ()
◆ Spliti ()
These functions all accept a regular expression string as its first parameter. PHP uses the POSIX extension regular expression defined by POSIX 1003.3. For a complete description of POSIX regular expressions, see the man page in the regex Directory of the PHP release package. You can use commands similar to man/usr/local/src/regex/regex.7.
Requirement: you can add external library files to the support of this extension module.
Installation warning: do not change the TYPE unless you know what you are doing.
To activate regexp support, add -- with-regex [= TYPE] when configuring PHP. TYPE can be system, apache, or php. Php is used by default.
PHP Windows has built-in support for this extension module. You can use these functions without loading any additional extension libraries. Let's take a look at the specific operations:
◆ Runtime configuration: no setting commands are defined for this extension module.
◆ Resource type: this extension module does not define any resource type.
◆ Predefined constant: this extension module does not define any constants.
Example of a PHP regular expression function:
-
- // If "abc" is found anywhere in $ string, & true;
- Ereg("Abc",$ String);
-
- // If $ string starts with "abc", & true;
- Ereg("^ Abc",$ String);
-
- // If $ string ends with "abc", return & true;
- Ereg("Abc $",$ String);
-
- // If your browser is Netscape 2, 3 or MSIE 3, & true;
- Eregi("(Ozilla. [23] | MSIE.3 )",$ HTTP_USER_AGENT);
-
- // Put words separated by three spaces in $ regs [1], $ regs [2], and $ regs [3]
- Ereg("([[: Alnum:] +) ([[: alnum:] +)
- ([[: Alnum:] + )",$ String,$ Regs);
-
- // Set
Mark it at the beginning of $ string
- $ String=Ereg_replace("^","
",$ String);
-
- // Set
Mark to end with $ string
- $ String=Ereg_replace("$","
",$ String);
-
- // Delete all linefeeds in $ string
- $ String=Ereg_replace("N","",$ String);
- ?>
The introduction of PHP regular expression functions will introduce you here. I hope you can understand and learn PHP regular expression functions.
Why? Here we will introduce you to the PHP regular expression function library (POSIX extension) greedy Matching. we should note that in the condition submode and many other...