How to replace <span style="font-weight: bold;">foo</span> by <strong>foo</strong> using PHP and regex?
I have a string like this:
&l开发者_StackOverflowt;span style="font-weight: bold;">Foo</span>
I want to use PHP to make it
<strong>Foo</strong>
…without affecting other span
s.
How can I do this?
$text='<span style="font-weight: bold;">Foo</span>';
$text=preg_replace( '/<span style="font-weight: bold;">(.*?)<\/span>/', '<strong>$1</strong>',$text);
Note: only work for your example.
精彩评论