Seas.Comander Posted September 5, 2009 Share Posted September 5, 2009 I've been working on this forever now and am tired of not finding the answer so I'm just going to ask here. I need to find the following consecutive 6 lines that appear in many of my .html pages, I'm going to replace those lines with new html... </center> </td> </tr> </table> </td> </tr> This is what I've come up with for this right now, but as you probably can see just by looking at it, it doesn't work. $content = preg_replace('|</center>(.*$)</td>(.*$)</tr>(.*$)</table>(.*$)</td>(.*$)</tr>|ms', $extra, $content); Link to comment https://forums.phpfreaks.com/topic/173256-easy-preg_match-problem/ Share on other sites More sharing options...
.josh Posted September 5, 2009 Share Posted September 5, 2009 '~</center>.*?</td>.*?</tr>.*?</table>.*?</td>.*?</tr>~s' Link to comment https://forums.phpfreaks.com/topic/173256-easy-preg_match-problem/#findComment-913289 Share on other sites More sharing options...
thebadbad Posted September 5, 2009 Share Posted September 5, 2009 I'm not actually sure why your pattern doesn't work, but it must have something to do with the 'inline' end-of-line anchors. You should just use \s* (zero or more whitespace characters) instead: $content = preg_replace('|</center>\s*</td>\s*</tr>\s*</table>\s*</td>\s*</tr>|i', $extra, $content); I also made the search case insensitive. Link to comment https://forums.phpfreaks.com/topic/173256-easy-preg_match-problem/#findComment-913303 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.