Liquix Posted May 5, 2007 Share Posted May 5, 2007 I got this regexp: $regexp = '#<div class="profile-info">.*?name-text">(.*?)</span>.*?birthday date.*?\s+([\S]+).*?<div>.*?([ ]+<img src="([^"]+))*.*?<div class="profile-figure">.*?src="([^"]+).*?</div>.*?<div class="profile-motto">(.*?)<div#sm'; In the code you can find this: ([ ]+<img src="([^"]+))* There is a crash between backtrace and making the string between the outer braces alternative there. If the code between the outer braces isn't in the text Im searching in, I want ([^"]+) to return an empty variable instead of making the whole regexp crash! Any way to do this? (The * at the end is to make the content of braces be one or zero times) Quote Link to comment Share on other sites More sharing options...
MadTechie Posted May 5, 2007 Share Posted May 5, 2007 ok well that regex isn't making sense to me, also what are you trying to search for ? Quote Link to comment Share on other sites More sharing options...
Liquix Posted May 5, 2007 Author Share Posted May 5, 2007 Im searching for different information from an external webpage. In PHP the () is used as backtraces to get infromation to an array. One of the elements I want to add to the array is alternative and isnt always set.. I want the var to be empty if the specific image isnt in the code Quote Link to comment Share on other sites More sharing options...
MadTechie Posted May 5, 2007 Share Posted May 5, 2007 and the problem is ? Quote Link to comment Share on other sites More sharing options...
effigy Posted May 7, 2007 Share Posted May 7, 2007 Make it optional with (?: pattern )?. 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.