Regular Expression Pattern Problem
Moderator: General Moderators
-
CyberSpatium
- Forum Newbie
- Posts: 21
- Joined: Thu Mar 20, 2003 12:23 pm
- Contact:
Regular Expression Pattern Problem
I am having a heck of a time finding a regular expression pattern that works for a simple text string. i have a form field where users enter their name. if can be just their first name, first and last name, or just a nickname (max length is 30 characters).
I am trying to use ereg_match() to verify it is in the correct format. but I have tried pattern after pattern and I cannot get one to work.
any help would be greatly appreciated.
CyberSpatium
I am trying to use ereg_match() to verify it is in the correct format. but I have tried pattern after pattern and I cannot get one to work.
any help would be greatly appreciated.
CyberSpatium
-
CyberSpatium
- Forum Newbie
- Posts: 21
- Joined: Thu Mar 20, 2003 12:23 pm
- Contact:
well, for security reasons, i am checking it to maker sure that only text has been submittted by the form, nothing else. so, the only thing allowed to be submitted text and a space, and that is what i am trying to limit it to with this pattern, but I have not been able to get one to work.
thx
cyberspatium
thx
cyberspatium
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
Code: Select all
[a-zA-Z ]{1,30}play here: http://www.cuneytyilmaz.com/prog/jrx/
- stereofrog
- Forum Contributor
- Posts: 386
- Joined: Mon Dec 04, 2006 6:10 am
Re: Regular Expression Pattern Problem
You have to define "name" more exactly. Are names like "O'Malley-Finkel-Harris-Smith" allowed? Is "^%&^%@#" a valid nickname?CyberSpatium wrote:I am having a heck of a time finding a regular expression pattern that works for a simple text string. i have a form field where users enter their name. if can be just their first name, first and last name, or just a nickname (max length is 30 characters).
I am trying to use ereg_match() to verify it is in the correct format. but I have tried pattern after pattern and I cannot get one to work.
any help would be greatly appreciated.
CyberSpatium
This will match, among others, the string of 30 spaces.[a-zA-Z ]{1,30}
-
CyberSpatium
- Forum Newbie
- Posts: 21
- Joined: Thu Mar 20, 2003 12:23 pm
- Contact:
-
CyberSpatium
- Forum Newbie
- Posts: 21
- Joined: Thu Mar 20, 2003 12:23 pm
- Contact:
- kaisellgren
- DevNet Resident
- Posts: 1675
- Joined: Sat Jan 07, 2006 5:52 am
- Location: Lahti, Finland.