• Post Reply Bookmark Topic Watch Topic
  • New Topic

strip punctuation  RSS feed

 
Peyton Maddox
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to strip the punctuation from strings that are read from a file and am not having much luck with it. What I tried is the following:

line.replaceAll("\\W", "");

with "line" being the line that was just read from the text file. The lines are read correctly and outputted as I want, but the punctuation is not stripped. I'm hoping there is just something simple wrong with my approach but I am open to any suggestions on how to strip punctuation. Thanks.
 
Dana Bothner-By
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you forget that strings are immutable?
 
Peyton Maddox
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yep. Thanks a ton!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!