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

Regular expressions ... Pls help

 
Chirag Dua
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a string like this: cmCreateProductviewTag('<dynamic data>','<dynamic data>','<dynamic data>')

I want to remove single quotes and double quotes inside dynamic data strings ONLY
[ October 08, 2005: Message edited by: Michael Ernest ]
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may use split, to split the String, and replace the splitted parts separately, and handle the first and last element separately:


How to handle empty Strings, or lists of only one String ('<dynamic foo>') is left as an excercise...
 
Alan Moore
Ranch Hand
Posts: 262
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are some problems with Stefan's code, but the basic premise is correct; you can't do this replacement in a single stage using regexes. Here's another approach:I'm assuming the dynamic data is always surrounded by single quotes and angle brackets. If that isn't the case, you'll need some other way to identify it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic