Reputation: 3761
I have string for example: hasan عمرانی
.
I want to match persian chars for the whole string. I mean if the string is not entirely persian the regex doesn't match any character.
I have this pattern so far:[\x{0600}-\x{06FF}\s]+
. but it matches عمرانی
.
It must not match any of the string.
please help me to provide a pattern. Thanks.
Upvotes: 4
Views: 611
Reputation: 3643
You can add ^
at the beginning of your expression and $
at the end, to try to match from the beginning to the end of the string being searched.
^[\x{0600}-\x{06FF}\s]+$
Tested it and it works on Regex101
Upvotes: 2
Reputation: 784998
You can use \p{Old_Persian}
property instead of range:
^\p{Old_Persian}+$
Upvotes: 3