...

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



danbopes
01-07-2010, 01:21 PM
http://xrg.es/?631614439

Having an issue trying to match.

The string is simple:


$options[one][two][three]


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?

JAY6390
01-07-2010, 01: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