Matching Arabic Regular Expression Text

I am trying to match only Arabic text using a regular expression, but I am getting an exception. Here is my code:

txt.matches("\\P{Arabic}+") 

Here's the exception:

An exception in the "main" thread java.util.regex.PatternSyntaxException: Unknown symbol property name {Arabic} next to index 9 \ P {Arabic} +

+6
source share
1 answer

Use this character block.

 \p{InArabic}+ 

In java, Unicode scripts, blocks, categories, and binary properties are written using \p and \p (negative effect)

  • Scripts are specified either with the Is prefix or with the script keyword ( supported scripts )
  • Blocks are indicated with the prefix In or using the keyword block ( supported blocks )
  • Categories can be specified with the optional prefix Is or using the keywords general_category or gc ( supported categories )
  • Binary properties are prefixed with Is ( supported properties )

REFERECE

+12
source

Source: https://habr.com/ru/post/950379/


All Articles