Phppreg_replace is used to solve the problem. there is a text section 123456 & lt; a & nbsp; href = "" & gt; abcdefg & lt;/a & gt; sdfsdafdfabcdffsafd. objective: replace the abc that appears for the second time. for the first time, do not perform Cainiao or $ str php preg_replace.
Such as the question, there is a piece of text
123456 abcdefgsdfsdafdfabcdffsafd
Purpose: replace the abc that appears for the second time.
Cainiao solution
------ Solution --------------------
$ Str = '123456abcdefgabceeesdfsdafdfabcdffsafdabcdefg ';
$ Str = preg_replace ('/(? <= ..(? ) Abc/iU ',' --- ', $ str );
Echo $ str ,'
';
Applicable only to tags
------ Solution --------------------
$ Str ='Semiconductor material semiconductor manufacturing plant, conductor Semiconductor
';
$ Str = preg_replace ('/(conductor )(?! (:? [^ <]
------ Solution --------------------
<(?! A) [^>] *>) * <\/a>)/imu ',' $ 1', $ str );
Echo $ str;
...... This is