I'd like to have a regular expression rule that matches to texts where 1. has Japanese characters (= English only text is not allowed) 2. can have English (alphabetical) characters 3. can have other arbitrary common symbols such as -,.。、!!??@@・'’0-9
.
The following meets 1. has Japanese characters, but not 2 and 3.
var regex = /^[^\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Han}\p{Script=Katakana_Or_Hiragana}\p]+$/
"パイソンが得意です".match(regex) // matches
"pythonが得意です".match(regex) // does not match
"I'm good at python.".match(regex) // does not match
The problem is that, the following still doesn't meet 2, 3, while I expected it to meet the all of three.
var regex = /^[^\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Han}\p{Script=Katakana_Or_Hiragana}\pA-Za-z\s'\.]+$/
"パイソンが得意です".match(regex) // matches
"pythonが得意です".match(regex) // still does not match
"I'm good at python.".match(regex) // still does not match
So, what's the problem to fix the regex rule?