the question sounds a bit confusing, but it is actually straightforward. This is a follow-up of my previous post:
Need a little help on this regular expression
after successful transformation of the String, now the String looks like:
<media id="pc011018" rights="licensed"
type="photo">
<title>Sri Lankans harvest tea</title>
Now the only task left is to swap the three attributes of media node, so the output String should be:
<media type="photo" id="pc011018" rights="licensed">
<title>Sri Lankans harvest tea</title>
I actually could think of a way of doing this: first of all, I extract the string enclosed by the first pair of "[" bracket. Then for this string, I will use a StringTokenizer to tokenize three attributes strings: type, id, rights; then rearrange them in a StringBuffer,turn it back into a string, then finally concatenate with the remaining [title] substring.
I am just wondering if there is a better and more efficient way rather than using StringToknizer? Please kindly help, thanks.