aspose file tools*
The moose likes Java in General and the fly likes Regular expressions ... Pls help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Regular expressions ... Pls help" Watch "Regular expressions ... Pls help" New topic
Author

Regular expressions ... Pls help

Chirag Dua
Greenhorn

Joined: Oct 08, 2005
Posts: 1
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

Joined: Jun 02, 2003
Posts: 1923

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...


http://home.arcor.de/hirnstrom/bewerbung
Alan Moore
Ranch Hand

Joined: May 06, 2004
Posts: 262
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Regular expressions ... Pls help