In the text analysis of the time we often need to filter out the stop words, punctuation and so on, this article to explain how to identify and delete all the punctuation in the text. Here are three feasible regular expression scenarios, children's shoes try it ^_^
(1) S.replaceall ("\\p{punct}", "");
(2) S.replaceall ("\\pP", "");
(1) Do not fully understand all punctuation, (2) and (3) equivalence can be completely clear punctuation (both in Chinese and English can be clear) it should be noted that there are some systems do not think that the punctuation of half-width and full-width symbols can not be cleared, as follows:
+~$ ' ^=|<>~ ' $^+=| <> ¥x
After modification:
(2) S.replaceall ("[\\pp+~$ ' ^=|<>~ ' $^+=| <> ¥x]", "");
The above three scenarios are given in the form of Unicode punctuation properties of regular expressions, you can remove all punctuation, including full-width, half-width, horizontal, vertical and other punctuation.
Note that full-angle single quotation marks and double quotation marks are not supported in an environment that is JDK 5 or below. In JDK 6, the PI and Pf two Unicode child properties are added so that they can be replaced.
This can be done in the version below JDK 6:
s = S.replaceall ("[\\pP '" ""] "," ");