[Pmwiki-users] comedy regex discoveries ;)

Ciaran ciaranj
Fri Jul 30 10:40:00 CDT 2004


I've *finally* figured how to do the reg-ex I've been wanting for ages
to do the knowledge base stuff :

preg_match_all("/(\\w+)(?:\s)*=(?:\s)*“(.*?)”/",
$fielddefs, $matches, PREG_PATTERN_ORDER);

	for ($i=0;$i<count($matches[1]);$i++)   {
		    print $matches[1][$i]." ==> ".$matches[2][$i]."<br/>";
	}


This strips a set of name/value pairs such as 
   colums="data" foo="moredata" bob = "somemoredata"

And fills the $matches array up with it, may be handy for someone so I
thought I'd share it.
Note the '&rdquo;' I must've spent 4 hours scratching my head as to
why ["] and [^"] were failing, it was pure co-incidence that I though
of this posibility, doh! Shjould've been checking my browser source
more closely!!!!!

-- 
- Ciaran
http://www.wombatinvasion.com/ (Share the love)



More information about the pmwiki-users mailing list