PHP mb_ereg_search() Function Last Updated : 11 Apr, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report The mb_ereg_search() is a PHP function used to search & match for a regular expression pattern in a string using multi-byte characters. It is similar to preg_match() but works with multi-byte characters. Syntax: mb_ereg_search(?string $pattern = null, ?string $options = null): boolParameters: This function accepts the two parameters that are described below: pattern: A regular expression pattern search for. It must be a valid regular expression for searching for a specific pattern in the string.options: This is an optional parameter. A string that specifies the search options. Return Value: This function returns "true" if the multibyte string matches with a given regular expression otherwise returns "false". Example 1: The following code demonstrates the mb_ereg_search() function. PHP <?php $string = "Hello, world!"; mb_regex_encoding("UTF-8"); mb_ereg_search_init($string); if (mb_ereg_search("world")) { echo "Found 'world' in the string\n"; } ?> Output: Found 'world' in the string Example 2: The following program demonstrates the mb_ereg_serach() function. PHP <?php $targetString = "The quick brown fox jumps over the lazy dog."; $pattern = "america"; mb_internal_encoding("UTF-8"); mb_ereg_search_init($targetString, $pattern); if (mb_ereg_search()) { echo "The pattern was found in the target string.\n"; } else { echo "The pattern was not found in the target string.\n"; } ?> Output: The pattern was not found in the target string. Reference: https://www.php.net/manual/en/function.mb-ereg-search.php Comment More infoAdvertise with us Next Article PHP mb_ereg_search_init() Function N neeraj3304 Follow Improve Article Tags : PHP PHP-function PHP-Multibyte-String Similar Reads PHP mb_ereg_search_pos() Function The mb_ereg_search_pos() is an inbuilt function in PHP that is used in regular expressions to match a given string. It searches for the first occurrence of a pattern in the string and returns the starting position and the ending position of the match. Syntax:mb_ereg_search_pos( ?string $pattern = nu 2 min read PHP mb_ereg_search_init() Function The PHP mb_ereg_search_init() function is an inbuilt function that is used to initialize the multibyte regular expression for a search. It sets the target string and regular expression to be searched using the mb_ereg_search() function. Syntax: bool mb_ereg_search_init( string $string, ?string $patt 2 min read PHP mb_ereg_search_regs() Function The mb_ereg_search_regs() function is an inbuilt function in PHP that is used for regular expressions to match a given string. If the match is found, then it will return the matched part as an array. Syntax: mb_ereg_search_regs( ?string $pattern = null, ?string $options = null): array|falseParameter 2 min read PHP mb_ereg_search_setpos() Function The mb_ereg_search_setpos() function is an inbuilt function in PHP that is used for setting the starting point for the next regular expression that will be matched. Syntax: mb_ereg_search_setpos(int $offset): bool Parameter: This function accepts one parameter that is described below. $offset: This 1 min read PHP mb_ereg_search_getpos() Function The mb_ereg_search_getpos() function is an inbuilt function in PHP that retrieves the start position of the last match and the end position of the last match. It works with multibyte character sets. Syntax: mb_ereg_search_getpos(): int Parameters: This function does not accept any parameters. Return 2 min read PHP mb_ereg_search_getregs() Function The mb_ereg_search_getregs() function is an inbuilt function in PHP that is used for matching substrings in the last multibyte regular expression match. It can be used after calling mb_ereg_search() or mb_ereg_search_pos() functions. Syntax: mb_ereg_search_getregs(): array|false Parameters: This fun 1 min read Like