Use the PHP string regular expression replacement function preg_replace. 1. preg_replace () $ msgpreg_replace (style. + styleis, $ msg); ----- delete stylestyle and the middle part $ msgpreg_replace ([^] +, $ msg); ----- is the delete and inner
1. preg_replace ()
$ Msg = preg_replace ("/ And the middle part
$ Msg = preg_replace ("/<[^>] +>/", "", $ msg); ----- delete <> and intermediate content
I (PCRE_CASELESS)
If this modifier is set, characters in the mode match both uppercase and lowercase letters.
S (PCRE_DOTALL)
If this modifier is set, the DOT metacharacters (.) in the pattern match all characters, including line breaks. If this parameter is not set, line breaks are not included. This is equivalent to the/s modifier of Perl. For example, [^ a] always matches a line break, regardless of whether this modifier is set.
2. ereg () and eregi ()
Note: The preg_match () function is usually a faster alternative than ereg ().
Eregi (" ] +)> (. +)", $ Data, $ B) ---- check whether the $ data contains the body tag. If yes, assign $ B [0] to the parameter and $ B [1] to the intermediate part.
Bool ereg (string pattern, string [, array regs])
Int eregi (string pattern, string, array [regs])
Eregi () and ereg () are similar in usage. The difference is that ereg () is case sensitive, and eregi () is not case sensitive.
Http://www.bkjia.com/PHPjc/323817.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/323817.htmlTechArticle1. preg_replace () $ msg = preg_replace ("/style. + \/style/is "," ", $ msg); ----- delete the style/style and the middle part $ msg = preg_replace ("/[^] + /", "", $ msg); ----- is in the middle of the delete and...