2

I have this regex: https://regex101.com/r/bM5sQ0/2

<input type="text" pattern="[\p{L}]+\s[\p{L}]+">

Wich I try to match the following text patterns:

Firstname Surname
Fírstnámé Súrnámé

And dismatch these lines:

Firstname Surname000
Fírstnámé Súrnámé000

I want to solve this globally with defining every unicode letter (what if someone is not hungarian, but polish, german, french,or spanish instead and I didn't included there special characters?). However my solution does not work.

Lanti
  • 2,139
  • 2
  • 31
  • 63
  • 1
    As far as I know, every strange character has a unicode code. So you have to be more specific than that. For now all I can see is `/^\D+$/`, i.e. everything except numbers. See here: https://regex101.com/r/zK0qA7/1 – Tamas Rev May 17 '16 at 15:39

1 Answers1

3

I can easily tell you why your solution does not work. If you look at the explanation at regex101.com, you'll see:

\p matches the character p literally (case sensitive)

{L} a single character in the list {L} literally (case sensitive)

JavaScript does not support the construct \p{}. If you really wish that they did support it, I suggest that you try the solutions here: https://stackoverflow.com/a/8933546.

If you just don't like digits, then you can use \D as tamas rev said in the comments.

Community
  • 1
  • 1
Laurel
  • 5,771
  • 12
  • 29
  • 54