Re: Re: regex
| From: | Philip Thompson | Date: | Wed, 13 Aug 2008 22:15:08 +0000 |
| Subject: | Re: Re: regex | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-278060@lists.php.net to get a copy of this message | ||
On Aug 13, 2008, at 4:06 PM, Boyd, Todd M. wrote:
Good call! I so passed over that one. ;) Thanks, ~Philip-----Original Message----- From: Shawn McKenzie [mailto:nospam@mckenzies.net] Sent: Wednesday, August 13, 2008 3:31 PM To: php-general@lists.php.net Subject: [PHP] Re: regex Philip Thompson wrote:I think /(.*)\.php\?action=([^&]+(?(&)[^&+]+))/ might be a step in the right direction for RegExing the additional URL query string parameters. I haven't tested it... but either way, I thought it was worth mentioning that the ".php" part should be "\.php" (or "[.]php"), otherwise it will match "any character followed by php." Todd Boyd Web ProgrammerFigured it out. Just needed to stretch my brain a lil. On Aug 13, 2008, at 3:07 PM, Philip Thompson wrote:appropriately?<?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 actionThat regex might not always work for you, (&) comes to mind. You might want to look at parse_str() which you can use after parse_url() if needed.Sorry, my regex is a lil rusty! Thanks in advance, ~PhilCheers, ~Philip