PHP regular expression processing non-matching items, for example ;?...? & Gt; code other than tag. For example, enclose curly braces. The requirement is to put the following code: aaa & lt ;?...? & Gt; bbb & lt ;?...? & Gt; ccc must be processed as follows: {aaa} & lt ;?...? & Gt; {bbb} & lt ;?...? & Gt; {ccc} Note & lt ;?...? & Gt; intermediate content and & lt ;?...? & Gt; other content are PHP regular expressions for non-matching items
For example Code other than the tag. For example, enclose curly braces.
The following code is required:
Aaa Bbb Ccc
To process it like this:
{Aaa} {Bbb} {Ccc}
Note: Intermediate content and Other content is not fixed.
What we need to deal with IS Something outside. Which are aaa, bbb, and ccc.
------ Solution --------------------
$ A = array ('/(.) <\? /','/\?> (.)/');
$ B = array ('$1} {$1 ');
Echo $ c = preg_replace ($ a, $ B, '{'. $ str .'}');
Test it by yourself
------ Solution --------------------
$ S = "aaa Bbb Ccc ";
Echo preg_replace ("/(^ | \?>) (. +) (<\? | $)/IU "," \ 1 {\ 2} \ 3 ", $ s );
{Aaa} {Bbb} {Ccc}