maxormark Posted May 26, 2009 Share Posted May 26, 2009 I know this is probably really easy, but it has me foxed. I need to know how to delete ... title="some random text string" ... from a longer string of code. There must be a way to isolate and remove a lump of text the format of which you cannot pre-determine. Basically, I'm trying to create a script which takes a web page and strips out a part of it to turn into an RSS feed. I've got it licked, except for the title tags. Alternatively, if anyone already has such a script, I'd be interested to know. Quote Link to comment https://forums.phpfreaks.com/topic/159750-solved-using-regex-to-delete-unknown-string/ Share on other sites More sharing options...
Axeia Posted May 26, 2009 Share Posted May 26, 2009 What exactly are you trying, extract a title attribute in full words up till a limit of a certain number of characters but they always need to remain full words? Quote Link to comment https://forums.phpfreaks.com/topic/159750-solved-using-regex-to-delete-unknown-string/#findComment-842592 Share on other sites More sharing options...
Ken2k7 Posted May 26, 2009 Share Posted May 26, 2009 <?php $str = 'title="some random text string"'; $str = preg_replace('#title=[\'"][^\'"]+?[\'\"]#','',$str); ? Quote Link to comment https://forums.phpfreaks.com/topic/159750-solved-using-regex-to-delete-unknown-string/#findComment-842599 Share on other sites More sharing options...
lordshoa Posted May 27, 2009 Share Posted May 27, 2009 I am sure this is what I asked earlier today and axeia gave me the answer [^"]*. $html = ereg_replace('title="[^"]*"','',$html); Quote Link to comment https://forums.phpfreaks.com/topic/159750-solved-using-regex-to-delete-unknown-string/#findComment-842795 Share on other sites More sharing options...
Ken2k7 Posted May 27, 2009 Share Posted May 27, 2009 preg > ereg Quote Link to comment https://forums.phpfreaks.com/topic/159750-solved-using-regex-to-delete-unknown-string/#findComment-842807 Share on other sites More sharing options...
maxormark Posted May 28, 2009 Author Share Posted May 28, 2009 Ken2k7 came up with just what I needed. Many, Many thanks Quote Link to comment https://forums.phpfreaks.com/topic/159750-solved-using-regex-to-delete-unknown-string/#findComment-844097 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.