This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Remove Punctuations with regex Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Remove Punctuations with regex" Watch "Remove Punctuations with regex" New topic

Remove Punctuations with regex

rakesh sugirtharaj
Ranch Hand

Joined: Dec 16, 2007
Posts: 151
IS there a way to remove punctuations in a String with Regex and Pattern matching?

Campbell Ritchie

Joined: Oct 13, 2005
Posts: 43368
Try the replaceAll method with punctuation passed as the first argument.
Darryl Burke

Joined: May 03, 2008
Posts: 4950

Read the API for java.util.regex.Pattern. There's a POSIX character class that matches punctuation.

Here's a great resource for better understanding of regex:
Learn How to Use and Get The Most out of Regular Expressions

luck, db
There are no new questions, but there may be new answers.
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 43368
I like the regular expression trail in the Java� Tutorials.
Don't get me started about those stupid light bulbs.
subject: Remove Punctuations with regex
jQuery in Action, 3rd edition