The regular expression matches all \ p {L} but not \ p {Alpha}

How can I match everything \p{L} but not \p{Alpha} in the regex? Is it possible to implement a logical AND in Java Regexp? If so, how can this be achieved?

+7
java regex logical operator-keyword
source share
2 answers

Yes, using a negative character class :

 [^\P{L}\p{Alpha}] 

[^\P{L}] same as \p{L} , but a negative character class allows you to subtract characters / properties from this character set.

+8
source share

Maybe, but it is specific to Java:

 [\p{L}&&[^\p{Alpha}]] 

(if necessary, indicated in the Java string, etc.)

+5
source share

All Articles