For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > January 2006 > regular expression









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author regular expression
Ashok

2006-01-10, 4:00 am

I want to check for regular expression a text description field, say 250
caracters max..
The field can contain only letters, numbers, comma and dot.
What will be the correct ereg php reg expression for this?
Can't figure out the proper expression.

Thanks.
Ashok


Stefan Rybacki

2006-01-10, 4:00 am

Ashok wrote:
> I want to check for regular expression a text description field, say 250
> caracters max..
> The field can contain only letters, numbers, comma and dot.
> What will be the correct ereg php reg expression for this?
> Can't figure out the proper expression.
>


something like this:

preg_match("/^[A-z0-9,.]*$/",$description);

Regards
Stefan

> Thanks.
> Ashok
>
>

Ashok

2006-01-10, 4:00 am

Must be I am not writing it correctly.
Currently I have without any validation
$formValidation->addField("user_link_description", true, "text", "", "", "",
"");
I want to exclude input of email, url and any php code. Just plain text.

Ashok

"Stefan Rybacki" <stefan.rybacki@gmx.net> wrote in message
news:40r9klF1c75tdU1@individual.net...[color=darkred]
> Ashok wrote:
>
> something like this:
>
> preg_match("/^[A-z0-9,.]*$/",$description);
>
> Regards
> Stefan
>


Jim Michaels

2006-01-16, 7:56 am

your regexp included some special characters in the ascii character set
there. also, the limit was not specified. dot must be escaped because it
normally matches any character, but I can't remember its behavior in
brackets...

preg_match("/^[A-Za-z0-9,\.]+{,250}$/",$description);

"Stefan Rybacki" <stefan.rybacki@gmx.net> wrote in message
news:40r9klF1c75tdU1@individual.net...[color=darkred]
> Ashok wrote:
>
> something like this:
>
> preg_match("/^[A-z0-9,.]*$/",$description);
>
> Regards
> Stefan
>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com