[thelist] PHP RegEx

Jon Molesa rjmolesa at consoltec.net
Wed Jul 11 22:47:23 CDT 2007


Wow, thank you for taking the time.

> Here's an option:
> 
> (?<=<a href="https?://)(.[^"]*)(" target="_new">)(.[^<]*)(?=</a>)
> 
> Returns:
> 
> group(0)  	www.Company.com" target="_new">Company

Can you explain to me why Group(0) is returned at all?  It looks as if
that's most of the regex and the first group appears to be optional or
passive is the term I think.  I just can't understand why the regex
comes with it.  Wouldn't that defeat the purpose of the regex in the
first place if you get back things you're not interested in?  OTOH, my
understanding is limited, and my regex is probably poorly written.
Nonetheless, understanding of regex's is what I'm seeking.  My
question is weather the php preg_match_all functions causes this
behavior, or is it my poorly constructed regex.  Thanks again.

> group(1)  	www.Company.com
> group(2)  	" target="_new">  	
> group(3)        Company
> 

-- 
Jon Molesa
rjmolesa at consoltec.net
if you're bored or curious
http://rjmolesa.com



More information about the thelist mailing list