-1

I would like to find a regular expresson for validating user input for FirstName and LastName. Is there som kind of standard for this? I would like to avoid strange signs, yet allow international signs like åäö, etc.

I am using .NET

Any recommendations?

lg.lindstrom
  • 776
  • 1
  • 13
  • 31
  • 2
    What language? Different language regexes have different built-in character classes – John Dvorak Jan 17 '14 at 14:15
  • See this answer: http://stackoverflow.com/a/8137467/898423 for the international signs problem. – Eduard Luca Jan 17 '14 at 14:15
  • 4
    [Falsehoods Programmers Believe About Names](http://www.kalzumeus.com/2010/06/17/falsehoods-programmers-believe-about-names/) – dee-see Jan 17 '14 at 14:25
  • possible duplicate of [Regex for names with special characters (Unicode)](http://stackoverflow.com/questions/5963228/regex-for-names-with-special-characters-unicode) – Bass Jobsen Jan 19 '14 at 12:29

2 Answers2

0

It seems that there is no single simple aswers. Closing this topic.

lg.lindstrom
  • 776
  • 1
  • 13
  • 31
-1

This is not so easy to do.

One way to do it is like this:

[a-zA-Zåäö] etc.

Just add all the special characters needed to the list of allowed characters, but it's not how you should do it.

Instead, check this question on why this is a really difficult problem to solve:

What are all of the allowable characters for people's names?

Community
  • 1
  • 1
e h
  • 8,435
  • 7
  • 40
  • 58
  • Feels like I opened Pandoras box here..... but so far " What are all of the allowable characters for people's names?" are most to my likening.... Folowing the adwise in that question I should only have one name field and allow any printable unicode character. IS THERE a definition for printable unicode charachters??? – lg.lindstrom Jan 19 '14 at 11:09
  • Don't even attempt to do it this way. –  Jan 19 '14 at 15:37
  • Yes, don't do it this way. It is a world of pain. See the link in my answer instead. – e h Jan 19 '14 at 20:36
  • I followed your link emh,,, and the conclusion on that thread are,, as I interpreted it, use one name field,, and allow "all printable" characters. Am I misunderstanding something here guys? (btw,, many links was broken in "What are all of the allowable characters for people's names?") – lg.lindstrom Jan 20 '14 at 09:22
  • Yes, that is pretty much it. There is a good answer that reads "If you absolutely must check the validity of someone's name, I'd suggest doing a modest blacklist of certain characters. Braces, mathematical characters, some punctuation and such might be safe to ignore. But I'd be cautious, if I were you." – e h Jan 20 '14 at 09:28