PHP mb_ereg_replace() Function Last Updated : 11 Apr, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report The mb_ereg_replace() is an inbuilt function in PHP that is used to search & replace a string using the regular expression. This function is similar to the preg_match() but works on the multibyte string. Syntax: mb_ereg_replace( $pattern, $replacement, $string, $options = null): string|false|null Parameters: The following function accepts four parameters that are described below. $pattern: This parameter used regular expression. It must be a valid regular expression.$replacement: The string that is replaced according to the pattern.$string: This is the string where we search our pattern.$option: This is an optional parameter that is used for the matching option. Example 'i' for case insensitive and 'm' for multiline characters or 's' for matching across lines. Return Values: This function returns the resulting string if the function successfully executes otherwise it will return "false" on error. Example 1: The following program demonstrates the mb_ereg_replace() function. PHP <?php $pattern = "[g]"; $replace = "G"; $return = mb_ereg_replace($pattern, $replace, "geeksforgeeks"); var_export($return); ?> Output: 'GeeksforGeeks' Example 2: The following program demonstrates the mb_ereg_replace() function. PHP <?php $pattern = "[geeks]"; $replace = "Geeks"; $return = mb_ereg_replace($pattern, $replace, "geeksforgeeks"); var_export($return); ?> Output: 'GeeksGeeksGeeksGeeksGeeksforGeeksGeeksGeeksGeeksGeeks' Reference: https://www.php.net/manual/en/function.mb-ereg-replace.php Comment More infoAdvertise with us Next Article PHP mb_ereg_replace_callback() Function N neeraj3304 Follow Improve Article Tags : PHP PHP-function PHP-Multibyte-String Similar Reads PHP mb_eregi_replace() Function The mb_eregi_replace() is an inbuilt function in PHP that is used to perform the replacement of regular expression characters. It is a case-insensitive regular expression search and replace with multi-byte character support. Syntax: mb_eregi_replace( string $pattern, string $replacement, string $str 2 min read PHP | ereg_replace() Function The ereg_replace() is an inbuilt function in PHP and is used to search a string pattern in an other string. If pattern is found in the original string then it will replace matching text with a replacement string. You may refer to the article on Regular Expression for basic understanding of pattern m 3 min read PHP mb_ereg_search() Function 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: Th 2 min read PHP mb_ereg_replace_callback() Function The mb_ereg_replace_callback() function is an inbuilt function in PHP that is used to replace a regular expression match in a string using the callback function. Syntax: mb_ereg_replace_callback( $pattern, $callback,$string,$options): string|false|null Parameters: The function accepts four parameter 2 min read PHP mb_ereg() Function The mb_ereg() function is an inbuilt function in PHP that is used for searching a string in the multibyte string by using the regular expression. Syntax: mb_ereg($pattern, $string, $matches ): bool Parameters: The following function has three parameters that are described below. $pattern: The regula 1 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 Like