Use a ready-made character class and limit it

Many ready-to-use character classes are available in Perl regular expressions such as \d or \S , or novice Unicode-grokkers such as \p{P} , which matches punctuation characters .

Now let me say that I would like to combine all the punctuation marks \p{P} (quite a lot of them, and not what you want to enter manually) - all but one, all but the good old coma (or comma,, )

Is there a way to specify this requirement without extending the convenient character class and taking away komma manually?

+7
source share
2 answers
 $ unichars -au '\p{P}' | wc -l 598 

Twice no:

 /[^\P{P},]/ $ unichars -au '[^\P{P},]' | wc -l 597 

And through lookahead / lookbehind:

 /\p{P}(?<!,)/ $ unichars -au '\p{P}(?<!,)' | wc -l 597 

unichars

+9
source

try it

 [^\P{P},] 

This is a negative character class that matches all but the listed characters.

\P{P} denied \P{P}

+7
source

All Articles