On 5/22/07, Zoltán Németh <[EMAIL PROTECTED]> wrote:
2007. 05. 22, kedd keltezéssel 03.35-kor Don Don ezt írta:
> Hi all, am trying to run a regular expression to a list of user entered data 
on some forms.
>
> I've creating what i think is a matching pattern for each category as shown 
below:
>
> function validateEntry($regularExpression, $fieldValue)
> {
>     if(preg_match($regularExpression, $fieldValue))
>     {
>         return "true";
>     }
>     else
>     {
>         return "false";
>     }
> }
>
> i made a list of rules that are passed into the function above
>
> 1)  [a-zA-Z][0-9] //allow any characters and numbers together anywhere within 
the text
> 2)  [a-zA-Z]      //allow only any charaters in the text
> 3)  [0-9]{2}      //allow only digits and they must be 2 in length
> 4)  [a-zA-Z]{1}   //allow only 1 character either uppercase or lowercase
>

the patterns seem ok, but you should enclose them within some delimiter
characters, e.g. "/[a-zA-Z][0-9]/" or something like that

greets
Zoltán Németh


Yes, but make sure you don't end up with a / inside your expression,
as that would mean the end of the expression.

You could also use another delimiter in your preg functions, i prefer
using the % symbol, but you could of course use anything you want :)

Tijnema

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

Reply via email to