String is considered valid if contains alphanumeric and _ and - and Thai characters, otherwise invalid. Characters like . or @ are invalid.
Based on the PHP documentation, the following regex should be working:
^[\w\-\p{Thai}]+$
It even seems to work as expected here: https://regex101.com/r/rfwjng/1
However doesn't work in my PHP code, nor working here: https://www.phpliveregex.com/p/wDf
private function containsInvalidCharacters($value) {
return !preg_match('/^[\w\-\p{Thai}]+$/', $value);
}
Update 1:
To clarify if I do /u at the end, it starts matching unwanted characters on my local machine. Although that seems to work on the referenced link (as suggested in the comment.)
Update 2:
Issue resolved when using '/^[\wก-๙-]+$/u'. For some reason \p{Thai} was not giving consistent results across PHP versions. See here: https://3v4l.org/4hB9e