the-botman Posted December 6, 2009 Share Posted December 6, 2009 hey guys ok see i need to replace everything inbetween this to tags and replace it with just a <br> p class="potMatchMenuText"> anything can be here more text or tags untill here<p class="potMatchHeading"> this is how it might show <p class="potMatchMenuText"><span class="cardMenu">Scorecard |</span> <span class="cardMenu">Commentary |</span> <span class="cardMenu">3D animation |</span> <span class="cardMenu">Article index (15) |</span> <span class="cardMenu">Photo index (60)</span> </p> <p class="potMatchHeading"> Thanks in advance Botman Link to comment https://forums.phpfreaks.com/topic/184203-regex-help/ Share on other sites More sharing options...
the-botman Posted December 6, 2009 Author Share Posted December 6, 2009 will this work? $tags = array('<p class="potMatchMenuText">','</p>'); $getmydata = str_replace($tags, '', $getmydata); Link to comment https://forums.phpfreaks.com/topic/184203-regex-help/#findComment-972506 Share on other sites More sharing options...
salathe Posted December 6, 2009 Share Posted December 6, 2009 Before posting a regular expression, can I just check that your desired output is: <p class="potMatchMenuText"><br><p class="potMatchHeading"> I only ask because it looks like that will break the HTML structure! Link to comment https://forums.phpfreaks.com/topic/184203-regex-help/#findComment-972510 Share on other sites More sharing options...
the-botman Posted December 6, 2009 Author Share Posted December 6, 2009 i got it $pattern = '%<p class="potMatchMenuText">(.+?)</p>%is'; $getmydata = preg_replace($pattern, '$2', $getmydata); thanks Link to comment https://forums.phpfreaks.com/topic/184203-regex-help/#findComment-972521 Share on other sites More sharing options...
cags Posted December 7, 2009 Share Posted December 7, 2009 Can I ask why your using $2 as the replacement pattern? Since you don't have a second capture group you are essential just replacing with a null string, so why not just use ''? Link to comment https://forums.phpfreaks.com/topic/184203-regex-help/#findComment-972759 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.