Re: Re: regex

From: Date: Wed, 13 Aug 2008 22:14:19 +0000
Subject: Re: Re: regex
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-278059@lists.php.net to get a copy of this message
On Aug 13, 2008, at 3:31 PM, Shawn McKenzie wrote:
Philip Thompson wrote:
Figured it out. Just needed to stretch my brain a lil. On Aug 13, 2008, at 3:07 PM, Philip Thompson wrote:
<?php function blegh ($subject) { // I know this pattern doesn't exactly work $pattern = '/(.*).php\?action=([^&].*)/';
$pattern = '/(.*).php\?action=([^&]+)+/';
preg_match ($pattern, $subject, $matches); return $matches; } blegh ('somePage.php?action=doSomething&id='); ?> Ok, the important parts that I need to obtain from this are: somePage doSomething How can you modify the pattern above to grab the action appropriately? Sorry, my regex is a lil rusty! Thanks in advance, ~Phil
Cheers, ~Philip
That regex might not always work for you, (&amp;) comes to mind. You might want to look at parse_str() which you can use after parse_url() if needed. -Shawn
That's a good thought. However, I am specifically sending a URL that has not yet been urlencoded, so I know that &amp; won't be occurring. Thanks, ~Philip

« previous php.general (#278059) next »