Pattern Matching
am 06.08.2009 23:57:12 von Floyd Resler
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
Re: Pattern Matching
am 07.08.2009 00:15:03 von Martin Scotta
--0016e64715d48f13e404708073fd
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
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
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 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
--0016e64715d48f13e404708073fd--
Re: Pattern Matching
am 07.08.2009 00:19:34 von Ben Dunlap
> 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.
Will your admin users know how to use regular expressions?
If not, can you reasonably anticipate the kinds of patterns the admins might
want to create, ahead of time? Or do you need to give them a really flexible
way to build any sort of pattern they please?
Ben
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Pattern Matching
am 07.08.2009 00:32:51 von Ralph Deffke
this side for shure is for help, lets u play arround with regex
http://gskinner.com/RegExr/
ralph
ralph_deffke@yahoo.de
"Floyd Resler" wrote in message
news:50FC5AB0-EE8B-4AC2-B982-9262A3977B8F@adex-intl.com...
> 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
Re: Re: Pattern Matching
am 07.08.2009 14:42:41 von Floyd Resler
Thanks to Martin's answer to my question (giving me the regular
expressions to my patterns) I can convert the patterns the admin users
enter into regular expressions.
Thanks!
Floyd
On Aug 6, 2009, at 6:19 PM, Ben Dunlap 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.
>
> Will your admin users know how to use regular expressions?
>
> If not, can you reasonably anticipate the kinds of patterns the
> admins might
> want to create, ahead of time? Or do you need to give them a really
> flexible
> way to build any sort of pattern they please?
>
> Ben
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Pattern Matching
am 07.08.2009 14:43:17 von Floyd Resler
--Apple-Mail-7-758858330
Content-Type: text/plain;
charset=US-ASCII;
format=flowed;
delsp=yes
Content-Transfer-Encoding: 7bit
Martin,
Thanks! Not only did that help tremendously but it also gave me a
better understand of regular expressions.
Thanks!
Floyd
On Aug 6, 2009, at 6:15 PM, Martin Scotta wrote:
> 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
>
>
>
> 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
> 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
--Apple-Mail-7-758858330--