[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 601
  • Last Modified:

Regex for full name

I need a regex for full name :

Only allow alpha numeric character (letter) and space.
0
softbless
Asked:
softbless
  • 3
  • 2
  • 2
  • +2
6 Solutions
 
tel2Commented:
Hi softbless.

Questions:
1. Does case (upper/lower) matter?
2. Is there a limit to the number of "words" it should match?

Think about names like:
    Joe de Guzman    (note "de" is all lower case, and there are 3 "words")
    Joe O'Gorman      (note quote and 3 uppercase chars)
0
 
chinawalCommented:
Depending up the where you are going to use RegEx, the RegEx pattern differ. However, the difference will be minor. There are numerous patterns.

Based on your requirement, this is the one :
^([a-zA-Z ']+)$


http://forums.devshed.com/regex-programming-147/full-name-string-match-556668.html
0
 
ozoCommented:
Only allow alpha numeric character (letter) and space.
^[a-zA-Z0-9 ]*$
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
tel2Commented:
Although the '*' should be changed to a '+', unless you're happy to accept names which contain nothing.
0
 
ozoCommented:
Nothing satisfies "Only allow alpha numeric character (letter) and space."
0
 
ozoCommented:
Btw, + still accepts names which contain only spaces.
0
 
käµfm³d 👽Commented:
>>  kaufmed , please make these clear :
>>  @" value=' . *'"
>>  why @ here?

I don't see where I used it, but the @ in front of a string literal turns the string into a raw string where backslashes are literal characters and not the escape character that they normally are.


Pattern explanation : ( ? < = I N P U T [ ^ > ] * ? v a l u e = [ \ " ' ] ? ) [ ^ \ " ' > ] *

(?<=  ...  )        Positive lookbehind; find this, but don't consider it part of the match
INPUT             literal
[^>]*?              zero or more ( * ) of any chacter NOT ( [^ ... ] ) a closing bracket  ( > ). Non-greedy ( ? ), so stop searching at the first match
value=             literal
["']?                  zero or one ( ? ) of either ( [ ... ] ) a single or double quote. Note, the backslash is an escape for the doble quote and not part of the pattern
[^"'>]*             zero or more ( * ) of any character NOT ( "[^ ... ] )  a single or double quote or a closing bracket. Again, the double quote is escaped
0
 
käµfm³d 👽Commented:
Sorry, wrong post. I think my phone hates me. ; )
0
 
softblessAuthor Commented:
thanks
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 3
  • 2
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now