1. preg_replace()
$msg = preg_replace("//is", "", $msg); -----Delete and the middle part
$msg = preg_replace("/<[^>]+>/", "", $msg); ----- is to delete <> and the middle content
i ( PCRE_CASELESS)
If this modifier is set, the characters in the pattern will match both uppercase and lowercase letters.
s (PCRE_DOTALL)
If this modifier is set, the dot metacharacter (.) in the pattern matches all characters, including newlines. Without this setting, newline characters are not included. This is equivalent to Perl's /s modifier. Excluded character classes such as [^a] always match newlines, regardless of whether this modifier is set.
2. ereg() vs. eregi()
Note: The preg_match() function is usually a faster alternative than ereg()
eregi("
The above introduces the instructions for using replacewith PHP string regular replacement function preg_replace, including the content of replacewith. I hope it will be helpful to friends who are interested in PHP tutorials.