Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Remove Punctuations with regex

 
rakesh sugirtharaj
Ranch Hand
Posts: 151
  • 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: 49733
69
  • 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: 5148
11
Java Netbeans IDE Opera
  • 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: 49733
69
  • 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