View Full Version : Regular Expression /bb|[^b]{2}/

01-07-2010, 12:21 PM

Having an issue trying to match.

The string is simple:


I need to match "options", "one", "two", and "three", but my regular expression only matches "three".

Is there a simple way to pull all that information?

01-07-2010, 12:50 PM
Don't think you'll be able to do this with just one regex. You'll need to match $options then the [...][...][...] capturing them all, then do a preg_match_all on those

$text = '$options[one][two][three]';
preg_match('/\$(\w+)((\[\w+\])+)/', $text, $out);
preg_match_all('/\[\K[^\]]+/', $out[2], $out2);
$var_name = $out[1];
$arrays = $out2[0];

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum