Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Simple regex question

 
Nikos Stavros
Ranch Hand
Posts: 243
Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Nikos Stavros
Ranch Hand
Posts: 243
Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this seems to work pretty good

.replaceAll("\"{2,}", "\""))
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic