I want to find this pattern in a string <span style="text-decoration: underline;">Text here</span> and change the tags to <u>kusal</u>
How can I use preg_replace to do this?
Thanks
searching tags and replace
Moderator: General Moderators
- prometheuzz
- Forum Regular
- Posts: 779
- Joined: Fri Apr 04, 2008 5:51 am
Re: searching tags and replace
Like this:
Code: Select all
$text = '<span style="text-decoration: underline;">Text here</span>';
echo preg_replace('@<span\s*style="text-decoration:\s*underline;">(?:(?!</span>).)*</span>@i', '<u>kusal</u>', $text);