Re: preg_match help please

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Steve Turnbull wrote:
On Thu, 08 Sep 2005 19:27:49 +1200, Jasper Bryant-Greene wrote:

Something like

'/^\w+,\w+,\w*$/'

maybe? (untested)

http://php.net/reference.pcre.pattern.syntax


Thats got me a lot further - thanks

I reduced it slightly to '/^\w+,\w+,' because at the end there is the
possibility of an alpha-numeric character(s) OR nothing at all with the
exception of a possible line break (note possible)

It's the 'possibly nothing at all' which I am slightly stuck on

That's what the \w* means. That means "0 or more word-characters", as opposed to \w+ which means "1 or more word-characters. The $ after that means "end of string" which makes sure that it's the last thing in the string.

In other words, \w* means some word-characters, or nothing at all. You'd need to handle the newline in much the same way. The URL I gave you should help out a lot with that.

--
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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux