Page 1 of 1

New to regex, trouble with some code

Posted: Mon May 18, 2009 8:30 am
by luwin
EDIT: Ok, actually fixed my first problem.

Problem two though:

Is it possible to have a conditional to a preg_match_all? Lets say I want some text if something, if not, then I get something else. For example:

My trouble is that I have a site that is something like this:

Product: Product name
Production year: year
website: link

The website has a list of these. Trouble is that some products does not have a website (and therefore not a link). What happens when I do a preg_match_all in my code is that if product 3 does not have a website, but product 4 does, then product 3 is associated with product 4's site. And then product 4 is not associated with any site. How can I solve this problem?

I really appreciate any help!

Re: New to regex, trouble with some code

Posted: Wed May 20, 2009 9:03 am
by GeertDD
It is possible to include an empty match for products without a website. If you want a real regex, I suggest you supply us with an example source string of product data.