aspose file tools*
The moose likes Beginning Java and the fly likes Simple regex question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Simple regex question" Watch "Simple regex question" New topic
Author

Simple regex question

Nikos Stavros
Ranch Hand

Joined: Feb 24, 2006
Posts: 243

Hi again coders

I was wondering how I replace an arbitrary number of quotes in a string with only one quote

Ignoring the surrounding " "

I want

"""""elephant""" to become "elephant"
""""elephant"""""" to become "elephant"

etc


Jesus lives
Nikos Stavros
Ranch Hand

Joined: Feb 24, 2006
Posts: 243

this seems to work pretty good

.replaceAll("\"{2,}", "\""))
 
Don't get me started about those stupid light bulbs.
 
subject: Simple regex question