• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Remove Punctuations with regex

 
rakesh sugirtharaj
Ranch Hand
Posts: 151
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
IS there a way to remove punctuations in a String with Regex and Pattern matching?
 
Campbell Ritchie
Sheriff
Pie
Posts: 47229
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try the replaceAll method with punctuation passed as the first argument.
 
Darryl Burke
Bartender
Posts: 5115
11
Java Netbeans IDE Opera
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Campbell Ritchie
Sheriff
Pie
Posts: 47229
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I like the regular expression trail in the Java� Tutorials.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic