Requirement for writing a regular segment: extract the content (including {literal} and {/literal}) between {liter} and {/literal} in a string }), then, encrypt the md5 value and put it back in the original place. I wrote $ str = "in this way, the company's eldest brother reterty {literal} jpojp {/literal} ojo needs to write a regular expression highly.
Requirement: extract the content between {liter} and {/liter} in a string (including {literal} and {/literal}), encrypt the md5 value, and put it back to the original location.
I wrote it like this.
$ Str = "reterty {literal} jpojp {/literal} ojojwr154654654wete fan {literal} tigang's identity {/literal} rowetw, Guangdong province ";
$ New_str = preg_replace ('/\ {literal \}(.*?) \ {\/Literal \}/isum ', md5 ("$1"), $ new_str );
Print_r ($ new_str );
In this case, the md5 values in the two {liter} are the same and I don't know where the error is. please modify it (use the preg_replace function)
------ Solution --------------------
$ New_str = preg_replace ('/\ {literal \}(.*?) \ {\/Literal \}/ise ', 'md5 ("$1")', $ str );