Function name: mb_ereg_search_init()
Applicable version: PHP 4 >= 4.2.0, PHP 5, PHP 7
Usage: The mb_ereg_search_init() function is used to initialize multibyte regular expression search.
Syntax: mb_ereg_search_init(string $string [, string $pattern [, string $option]])
parameter:
Return value: Return TRUE if initialization is successful, otherwise FALSE.
Example:
// 初始化多字节正则表达式搜索mb_ereg_search_init("Hello World!", "[A-Za-z]+"); // 检查是否有匹配if (mb_ereg_search()) { echo "匹配到了"; } else { echo "没有匹配"; }
In the above example, we first use the mb_ereg_search_init() function to initialize a multi-byte regular expression search, specifying that the string to be searched is "Hello World!" and the regular expression pattern is "[A-Za-z]+", indicating that one or more upper and lower case letters are matched. Then, we use the mb_ereg_search() function to check if there is a match. If there is a match, the output "matched", otherwise the output "no match".
Note: Before using the mb_ereg_search_init() function, you need to make sure that the mbstring extension is enabled.