Could you please provide a concreate example? It's not clear what you are trying to do.
–
helpermethodSep 14 '11 at 16:54

Yeah, one example isn't enough because you haven't shown how the input can vary and how your code should handle the differences. Either post the actual requirements or enough examples that the requirements are self-evident.
–
Mark PetersSep 14 '11 at 16:57

I have added further examples. Input is a palindrome with few symbols inside.
–
Cengiz CanSep 14 '11 at 17:14

You can then implement a simple iteration over the given string, that takes single characters and convert them.

To implement the "inside three parentesis" you could use Java internationalization system, so you can write "inside {0} parentesis" and then, in the parser, when you meet the same char more than once, increment a counter and use it to format the string properly. Given that the syntax is quite powerful, you can easily manage to handle singulars, plurals etc..

Thanks. I decided to go with a temporary map and increment the counts while I iterate over the input string. I guess no easy way around with regular expressions is possible.
–
Cengiz CanSep 14 '11 at 17:18

I do agree, regexs are powerful beasts, but still beasts :D
–
Simone GianniSep 14 '11 at 17:20

will check on that. Thanks for the suggestion.
–
Cengiz CanSep 14 '11 at 17:12

You cannot match arbitrarily deep nesting. You can certainly match and remove the outermost paired brackets, remove them, and loop; and you can certainly write a regular expression to pick apart well-formed paired brackets to a particular depth, but coping with errors is a drag, and the expression will be hard to write and debug for any nontrivial depths, and anyway, a real parser is a better tool for this.
–
tripleeeSep 14 '11 at 18:16