2

Python string class has a string property named punctuation, and it contains almost all the punctuation I need to deal with.

It looks like:

import string
print string.punctuation          #!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~

I wonder whether Java also has this string property, in any classes come with Java?

Jay Wang
  • 2,650
  • 4
  • 25
  • 51
  • 1
    As far as i know not directly in the String class, but the regex pattern can identify a punctuation character like given in the second answer of [this question](http://stackoverflow.com/questions/13925454/check-if-string-is-a-punctuation-character) – SomeJavaGuy Jan 18 '16 at 13:52
  • 3
    Who is "we" in this case? Punctuation requirements will vary significantly by culture and use case. – Jon Skeet Jan 18 '16 at 13:54
  • @jonSkeet Thanks, editted. – Jay Wang Jan 18 '16 at 13:55
  • 2
    As @Kevin Esche says, _java.util.regex.Pattern_ supports "\p{Punct}" Punctuation: One of !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~ – Arnaud Jan 18 '16 at 13:58
  • 1
    Well how do we know which punctuation *you* need to deal with? If you just want *those* punctuation characters, you can easily define your own constant... but are you sure you don't need to support other cultures? – Jon Skeet Jan 18 '16 at 14:28

0 Answers0