Need help with a regular expression please.

This is a discussion on Need help with a regular expression please. within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hi. I'm trying to create a regular expression for a form field validation that would permit input something like ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 08-06-2005
marcy klein
 
Posts: n/a
Default Need help with a regular expression please.

Hi. I'm trying to create a regular expression for a form field validation
that would permit input something like this:

+1 (1-23) 321.1234 ext.12

Any numbers 0-9, plus signs, parentheses (open and close), periods (dots),
hyphens, alpha characters e, x, and t, and blank spaces.

I have thus far been working with:

^[0-9ext\(\)\+\.\-]*$

Hmm, I should make the alpha characters case insensitive as well. But the
problem I'm having is including blank spaces. As you can see from the
example input string above, there are blank spaces in the string. Thus far,
however, I've not been able to construct my regular expression to permit
blank spaces. Any suggestions or help would be appreciated. TIA (Running
Mandrake Linux, BASH, PHP.)

Marcy


Reply With Quote
  #2 (permalink)  
Old 08-06-2005
William Park
 
Posts: n/a
Default Re: Need help with a regular expression please.

In <comp.unix.shell> marcy klein <no_email@noemail.com> wrote:
> Hi. I'm trying to create a regular expression for a form field validation
> that would permit input something like this:
>
> +1 (1-23) 321.1234 ext.12
>
> Any numbers 0-9, plus signs, parentheses (open and close), periods (dots),
> hyphens, alpha characters e, x, and t, and blank spaces.
>
> I have thus far been working with:
>
> ^[0-9ext\(\)\+\.\-]*$
>
> Hmm, I should make the alpha characters case insensitive as well. But the
> problem I'm having is including blank spaces.


^[ 0-9ext()+.-]*$

> As you can see from the
> example input string above, there are blank spaces in the string. Thus far,
> however, I've not been able to construct my regular expression to permit
> blank spaces. Any suggestions or help would be appreciated. TIA (Running
> Mandrake Linux, BASH, PHP.)
>
> Marcy


--
William Park <opengeometry@yahoo.ca>, Toronto, Canada
ThinFlash: Linux thin-client on USB key (flash) drive
http://home.eol.ca/~parkw/thinflash.html
BashDiff: Super Bash shell
http://freshmeat.net/projects/bashdiff/
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 01:22 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0