I am trying to match Regex for certain Japanese characters blocks based on this post using the String.matches( String regex ) method in the class String.
But both the range regex [\\x3041-\\x3096]
and the property regex \p{Hiragana}
throw a PatternSyntaxException.
My IDE also recommends properties, but none of them Japanese characters seem to be recommended.
The code that throws this error is:
c.matches( "[\x3041-\x3096]" )
The StackTrace is:
[\x3041-\x3096]
^
at java.base/java.util.regex.Pattern.error(Pattern.java:2015)
at java.base/java.util.regex.Pattern.range(Pattern.java:2813)
at java.base/java.util.regex.Pattern.clazz(Pattern.java:2701)
at java.base/java.util.regex.Pattern.sequence(Pattern.java:2126)
at java.base/java.util.regex.Pattern.expr(Pattern.java:2056)
at java.base/java.util.regex.Pattern.compile(Pattern.java:1778)
at java.base/java.util.regex.Pattern.<init>(Pattern.java:1427)
at java.base/java.util.regex.Pattern.compile(Pattern.java:1068)
at java.base/java.util.regex.Pattern.matches(Pattern.java:1173)
at java.base/java.lang.String.matches(String.java:2024)
at lib.UIE.TextInput.valid(TextInput.java:49)