LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-19-2003, 06:57 PM   #1
chr15t0
Member
 
Registered: Jun 2002
Location: London
Distribution: Slackware
Posts: 201

Rep: Reputation: 30
validating a surname - regexp fu


hey folks

I seem to have got myself into a tangle with a bit of regexp work.

I need an expression which can be used to validate a surname, ie it will allow a-zA-Z , single spaces, hypens (-), single quotes (')

such that the following are passed:

Jones
O'reilly
Langly-Smith
Van Schnee

preferrably using PCRE syntax, with POSIX [:alpha;] - type expressions if needed.

anyone got such a regexp lurking?

thanks,
christo
 
Old 06-20-2003, 04:42 AM   #2
chr15t0
Member
 
Registered: Jun 2002
Location: London
Distribution: Slackware
Posts: 201

Original Poster
Rep: Reputation: 30
I have the following expressions, which allows letters, spaces and hyphens, but I can't get it to allow a single quote "'"

/^[a-zA-Z -]+$/

I wonder if anyone can work out how to add a single quote to a character class. I have tried various combinations without success.


thanks
christo

Last edited by chr15t0; 06-20-2003 at 04:45 AM.
 
Old 06-20-2003, 05:55 AM   #3
chr15t0
Member
 
Registered: Jun 2002
Location: London
Distribution: Slackware
Posts: 201

Original Poster
Rep: Reputation: 30
ha - I figured out the problem.. I had magic_quotes_gpc turned on.


doh!


christo
 
  


Reply



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 On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
validating.... javier_ccs Programming 5 06-15-2005 08:22 AM
Shell script, validating email and website Joey^s Programming 5 12-04-2004 05:31 PM
Validating user name/password kuna Programming 1 12-02-2004 10:39 PM
Validating rules file error. mike8994 Linux - Networking 0 09-05-2004 08:45 AM
validating user input blanks Programming 3 09-02-2004 03:47 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration