PHP preg_match not working as Input pattern


So I have this input pattern in HTML:

<input name="firstnamereg" type="text" pattern="[/\p{L}+/u ]+">

But When I use the preg_match it does not work:

$regexFirstANDLastname = "/[/\p{L}+/u ]+/";

preg_match($regexFirstANDLastname, $_POST["firstnamereg"]);


You need to use


This pattern, in Chrome and Firefox, will be compiles as a new RegExp("^(?:[\\p{L}\\s]+)$", "u") regex object. The u flag is used by default, you do not need to pass the flag in a regex literal construct. The pattern regex is always set with a string, not a regex literal.

Answered By – Wiktor Stribi┼╝ew

Answer Checked By – Clifford M. (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.