0

how to write regular expression allow name with one space and special Alphabets? I tried with this [a-zA-Z]+(?:(?:\. |[' ])[a-zA-Z]+)* but not working for me,

example string Björk Guðmundsdóttir

Vhndaree
  • 594
  • 1
  • 6
  • 20

2 Answers2

0

You may try something along these lines:

^(?!.*[ ].*[ ])[ A-Za-zÀ-ÖØ-öø-ÿ]+$

The first negative lookahead asserts that we do not find two spaces in the name. This implies that at most one space is present (or no spaces at all). Then, we match any number of alphabets, with most accented letters included. Spaces can also be matched, but the lookahead would already ensure that at most one space can be present.

Demo

Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360
-1

Use this one:

[a-zA-Z\u00C0-\u00ff]*[ ]{1}[a-zA-Z\u00C0-\u00ff]*

Answer from other question

Arthur
  • 11
  • 2
  • Replace {1} with ? sign for 0 or 1 space included. [a-zA-Z\u00C0-\u00ff]*\s?[a-zA-Z\u00C0-\u00ff]* – Arthur Nov 15 '18 at 13:34