preg_replace string that has quotes

I have several strings that look like this:

<DT><H3 LAST_MODIFIED="1313761646">Text</H3>

The number is different in each string. I want to replace the LAST_MODIFIED portion of the string, the quotes, and the numbers inside the quotes. The final string would look like this:

<DT><H3>Text</H3>

I’ve been trying to use this PHP code without success:

[php]
$line=‘

Text

’;
$line=preg_replace(’/LAST_MODIFIED="\d+"/’,"",$line);
[/php]

I think I’m doing something wrong with the way my regular expression is handling the quotes but I can’t figure it out. Any ideas?

Try to update your regular expression line this:
[php]$line=preg_replace(’/\sLAST_MODIFIED="[\d]+"/’,"",$line);[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service