b00ker_b0y Posted August 10, 2007 Share Posted August 10, 2007 hey people, trying to use preg_replace to edit some text. For example, the following text has links and an image. I want the normal links to stay, and the breaks "< b r >" but i want the image and it link at the end to be removed. What ever i am doing is causing issues like messing up links of removing the breaks so i am doign something wrong. Spain had also regained its growth in the overall number of <a href="http://www.lamangaspain.com/index.htm" target="_blank">holidays</a> from the UK, after being hit by the rise in popularity of other cheap destinations such as Egypt, Turkey and Eastern Europe.<br/><br/>In total, Brits made over 12 million trips to Spain last year to spend more than £5 billion on their southern neighbours.<br/><br/>According to Mintel, agents were currently struggling in Spain, and needed to expand or appeal to a more high-end market to reverse the negative trend.<br/><br/>The research showed that the country's appeal to the young was falling as the 20 to 24 year old group was now the least likely to travel to the country.<br/><img alt="ADNFCR-1179-ID-18240457-ADNFCR" src="http://feeds.directnews.co.uk/feedtrack/adferocopyright.gif?feedid=1179&itemid=18240457" /> Any ideas truely are weclomed. Thanks people. Quote Link to comment Share on other sites More sharing options...
MadTechie Posted August 10, 2007 Share Posted August 10, 2007 can you post in code tags #1 what you have (want to change) #2 what you want #1 to look like after filtering also can a mod/admin move this to the correct section please EDIT: correct section is regex Quote Link to comment Share on other sites More sharing options...
b00ker_b0y Posted August 10, 2007 Author Share Posted August 10, 2007 hey, sorry did not know where to post this? thought i was in correct place. $logo_description = $news[Content]; $logoless_description = preg_replace("/<img/", "", $logo_description); $logoless_description = preg_replace(" />/", "", $logo_description); just want the text be the same with all the breaks, and links in tact, just with the image and its link on the end removed. Quote Link to comment Share on other sites More sharing options...
MadTechie Posted August 10, 2007 Share Posted August 10, 2007 OK but this foum has parsed the post so i have no idea what you want? can you post and example ie from The research showed that the country's appeal to the young was falling as the 20 to 24 year old group was now the least likely to travel to the country. <img src="test.jpg"> to The research showed that the country's appeal to the young was falling as the 20 to 24 year old group was now the least likely to travel to the country. Quote Link to comment Share on other sites More sharing options...
b00ker_b0y Posted August 10, 2007 Author Share Posted August 10, 2007 From: Spain had also regained its growth in the overall number of <a href="http://www.lamangaspain.com/index.htm" target="_blank">holidays</a> from the UK, after being hit by the rise in popularity of other cheap destinations such as Egypt, Turkey and Eastern Europe.<br/><br/>In total, Brits made over 12 million trips to Spain last year to spend more than £5 billion on their southern neighbours.<br/><br/>According to Mintel, agents were currently struggling in Spain, and needed to expand or appeal to a more high-end market to reverse the negative trend.<br/><br/>The research showed that the country's appeal to the young was falling as the 20 to 24 year old group was now the least likely to travel to the country.<br/><img alt="ADNFCR-1179-ID-18240457-ADNFCR" src="http://feeds.directnews.co.uk/feedtrack/adferocopyright.gif?feedid=1179&itemid=18240457" /> To: Spain had also regained its growth in the overall number of <a href="http://www.lamangaspain.com/index.htm" target="_blank">holidays</a> from the UK, after being hit by the rise in popularity of other cheap destinations such as Egypt, Turkey and Eastern Europe.<br/><br/>In total, Brits made over 12 million trips to Spain last year to spend more than £5 billion on their southern neighbours.<br/><br/>According to Mintel, agents were currently struggling in Spain, and needed to expand or appeal to a more high-end market to reverse the negative trend.<br/><br/>The research showed that the country's appeal to the young was falling as the 20 to 24 year old group was now the least likely to travel to the country.<br/> just want image knocked off the end, but the image could be different so have a different name so just need remove everthing between <img and />. <img alt="ADNFCR-1179-ID-18240457-ADNFCR" src="http://feeds.directnews.co.uk/feedtrack/adferocopyright.gif?feedid=1179&itemid=18240457" /> Quote Link to comment Share on other sites More sharing options...
MadTechie Posted August 10, 2007 Share Posted August 10, 2007 so this i think $data = 'Spain had also regained its growth in the overall number of <a href="http://www.lamangaspain.com/index.htm" target="_blank">holidays</a> from the UK, after being hit by the rise in popularity of other cheap destinations such as Egypt, Turkey and Eastern Europe.<br/><br/>In total, Brits made over 12 million trips to Spain last year to spend more than £5 billion on their southern neighbours.<br/><br/>According to Mintel, agents were currently struggling in Spain, and needed to expand or appeal to a more high-end market to reverse the negative trend.<br/><br/>The research showed that the country\'s appeal to the young was falling as the 20 to 24 year old group was now the least likely to travel to the country.<br/><img alt="ADNFCR-1179-ID-18240457-ADNFCR" src="http://feeds.directnews.co.uk/feedtrack/adferocopyright.gif?feedid=1179&itemid=18240457" />'; $data = preg_replace('/(<img.*>)$/i', '', $data); echo $data; EDIT: escaped the ' ;P Quote Link to comment Share on other sites More sharing options...
b00ker_b0y Posted August 10, 2007 Author Share Posted August 10, 2007 arh yes, thanks very much for your time and quick responce! not as complicated as i was trying to make it! cheers again Quote Link to comment Share on other sites More sharing options...
MadTechie Posted August 10, 2007 Share Posted August 10, 2007 welcome can you please click solved (bottom left) Quote Link to comment 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.