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); Quote 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' Quote 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. Quote Link to comment https://forums.phpfreaks.com/topic/173256-easy-preg_match-problem/#findComment-913303 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.