Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-07-2010, 12:21 PM   PM User | #1
danbopes
New Coder

 
Join Date: May 2006
Posts: 24
Thanks: 0
Thanked 4 Times in 4 Posts
danbopes is an unknown quantity at this point
Regular Expression /bb|[^b]{2}/

http://xrg.es/?631614439

Having an issue trying to match.

The string is simple:
PHP Code:
$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?
danbopes is offline   Reply With Quote
Old 01-07-2010, 12:50 PM   PM User | #2
JAY6390
Regular Coder

 
Join Date: Dec 2009
Location: UK
Posts: 495
Thanks: 0
Thanked 58 Times in 58 Posts
JAY6390 is on a distinguished road
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

PHP Code:
$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]; 
JAY6390 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:43 AM.


Advertisement
Log in to turn off these ads.