I am keen on using both [^\u0000-\u007F]+ and ^[A-Za-z0-9._-](?:[A-Za-z0-9._ -]*[A-Za-z0-9._-])?$ as a one regex but it's so complicated, I just couldn't make it work? Any ideas how to integrate both?
I want to use JavaScript version for client-side verification and Php version for server-side verification.
[^\u0000-\u007F]+this is for non-english alphabetical characters such asàèéìòóùàand this^[A-Za-z0-9._-](?:[A-Za-z0-9._ -]*[A-Za-z0-9._-])?$is for only letters, numbers, dot, dash, underscore and no whitespaces on the beginning and end.^[a-zàèéìòóùà0-9._-]+(?: [a-zàèéìòóùà0-9._-]+)*$with a case insensitive flag (but your question stay very unclear).\uXXXXnotation. However, there is a workaround. This^[\u0080-\uFFFF\w.-](?:[\u0080-\uFFFF\w. -]*[\u0080-\uFFFF\w.-])?$would match those letters. In JS, this regex can be used as is in literal notation.