Jump to content

Problem with alternative regexp


Liquix

Recommended Posts

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)

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.