GeeCON Prague 2014*
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


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,}", "\""))
 
GeeCON Prague 2014
 
subject: Simple regex question