Re: preg_match help please
| From: | Jasper Bryant-Greene | Date: | Thu, 08 Sep 2005 07:27:49 +0000 |
| Subject: | Re: preg_match help please | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-222011@lists.php.net to get a copy of this message | ||
Steve Turnbull wrote:
I am trying to find a regular expression to match a variable, what I think should work (but doesn't) is; preg_match ('^/[\w],[\w],/', $variable) The $variable MUST contain an alpha-numeric string, followed by a comma, followed by another alpha-numeric string, followed by another comma followed by (but doesn't have to!!) another alpha-numeric string followed by nothing. I realise my regex above doesn't allow for the last 'followed by nothing', but to me it looks like it should match the first part of the string up to the last comma?Something like '/^\w+,\w+,\w*$/' maybe? (untested) http://php.net/reference.pcre.pattern.syntax -- Jasper Bryant-Greene Freelance web developer http://jasper.bryant-greene.name/ If you find my advice useful, please consider donating to a poor student! You can choose whatever amount you think my advice was worth to you. http://tinyurl.com/7oa5s