During text analysis, we often need to filter out deprecated words and punctuation marks. This article describes how to identify and delete all punctuation marks in the text. The following are three feasible Regular Expression solutions. Let's try ^_^ [java] (1) s. replaceAll ("\ p {Punct}", ""); (2) s. replaceAll ("\ pP", ""); (3) s. replaceAll ("\ p {P}", ""); (1) cannot fully understand all punctuation marks, (2) and (3) it is equivalent to clear all punctuation marks (both Chinese and English). You must note that there are still some systems that do not consider punctuation halfwidth and fullwidth symbols to be irretrievable, as shown below: [java] ++ ~ $ '^ = | <> ~ Updated $ ^ + = | <> ¥ × after modification: [java] (2) s. replaceAll ("[\ pP ++ ~ $ '^ = | <> ~ Activities $ ^ + = | <> ¥ ×] "," "); (3) s. replaceAll (" [\ p {P} + ~ $ '^ = | <> ~ `$ ^ + = | <> ¥ ×] "," "); The preceding three schemes use regular expressions that use the Unicode punctuation attribute, you can remove all punctuation marks, including full-width, half-width, horizontal, and vertical. Note that full-angle single-quotation marks and double quotation marks cannot be replaced in JDK 5 or lower environments. Because the Pi and Pf Unicode sub-attributes are added to JDK 6, they can be replaced. In JDK 6 or lower versions, you can do this: [java] s = s. replaceAll ("[\ pP'' "]", "");