0

I have the following regex:

/^([\p{L}])*[\p{L},.'-]+$/u

it is a unicode version, which I use for international firstnames.

When I try this:

const value = "Hello"
const criteria = value.match(/^([\p{L}])*[\p{L},.'-]+$/u);
console.log(criteria);

It always returns null, no matter which value the variable has.

I tried it in Regex Debugger / Tester on a Browser and it worked there.

André
  • 1,078
  • 10
  • 22
  • This works for me with Chrome 76. Have you checked if your browser supports the Unicode Property Escapes (\p{...}) (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp#Browser_compatibility) ? It has been added fairly recently and may not be fully implemented everywhere. – Seblor Sep 10 '19 at 14:13
  • `/\p{L}/u` works in latest Node and Chrome releases so far. Use `XRegExp` to make a portable solution. Or [build the letter range ranges](https://stackoverflow.com/a/34854255/3832970) in your regex. – Wiktor Stribiżew Sep 10 '19 at 14:14
  • I think the problem is, that I am using create-react-app for it and apparently a babel plugin causes the problem.... does anyone have an idea? – André Sep 10 '19 at 15:03

0 Answers0