Is [[:punct:]] the only representation of punctuation proper?
Is [[:punct:]] the only representation of punctuation proper?
Is there a simpler one?
Is [[:punct:]] the only representation of punctuation proper?
Is there a simpler one?
You can build your own punctuation character set like this:
[.,!?;:'"(){}[\]<>/@#$%^&*+=_|\\-]
This is messy, prone to errors (you have to remember to escape ] and \?), and incomplete, depending on the characters you remember to include. Plus, it's easy to forget obscure punctuation like ¿, ¡, „, etc.
Another way is to use something like
\W (non-word character)
\W matches any character that’s not a letter, digit or underscore, so it includes punctuation but also:
spaces
tabs
symbols
line breaks
So you technically try [\W\D\H]
That would ignore words digits and horizontal spaces (not tested ... don't fret if it doesn't work I'm not on my computer).
So the POSIX for punct is the most comprehensive way.
Why do you ask?
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.