Ask php to extract the regular expression code string of the specified content from a string. the string is fhghfghdfpostm | a: 2: {I: 5; I: 0; I: 2; I: 0;} dsfdsdfsd may also be fhghfsdfsdfgdfgdfgdfgghdfpostm | a: 2: {I: 5; ask php to extract the regular expression code of the specified content from a string.
The string is fhghfghdfpostm | a: 2: {I: 5; I: 0; I: 2; I: 0;} dsfdsdfsd.
It may also be fhghfsdfsdfgdfgdfgdfgghdfpostm | a: 2: {I: 5; I: 0; I: 2; I: 0; I: 0; I: 0;} dsfdsdfsdsdfsdfgsdgsdg
I want to intercept the postm | a: 2: {I: 5; I: 0; I: 2; I: 0;} or postm | a: 2: {I: 5; I: 0; I: 2; I: 0; I: 0; I: 0; I: 0;} but the length of this string is not fixed.
------ Solution --------------------
PHP code
$ S = 'fhghfsdfsdfgdfgdfgdfgghdfpostm | a: 2: {I: 5; I: 0; I: 2; I: 0; I: 0; I: 0; I: 0 ;} dsfdsdfsdsdfsdfgsdgsdg '; echo preg_replace ('/. * (postm. + \}). */',' $ 1', $ s );