Re: Pattern Matching

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

 



here you have the regexp's

######## = \d{8}
AAAAAA = \w{6}
#A? = [\w\d]* (change the * for + to require at least 1 character)
##-A#A = \d\d-\w\d\w

<?php

if( 0 == preg_match('/\d{8}/', $user_input ))
    echo 'wrooong input';

# you can change the delimiters for any you like
# I prefer this one 'cause no need to escape the backslash \

if( 1 == preg_match('#[\w\d]+#', $user_input))
    echo 'it has alpha numeric and the "_" character';


On Thu, Aug 6, 2009 at 6:57 PM, Floyd Resler <fresler@xxxxxxxxxxxxx> wrote:

> I need some assistance in pattern matching.  I want allow the admin user to
> enter a pattern to be matched in my order form editor.  When someone then
> places an order I want to do a match based on that pattern.  Some of the
> examples I thought for the patterns are:
> ######## - must be numeric and 8 digits
> AAAAAA - must be alpha and 6 characters
> #A? - must be alphanumeric any length
> ##-A#A - must have two numbers, a dash, a letter, a number, and a letter
>
> I'm sure regular expressions are the answers but I am not well-versed in
> those at all and I'm not sure how to make the above patterns work in or even
> they are the best examples to use.  Any help would be greatly appreciated.
>
> Thanks!
> Floyd
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Martin Scotta

[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