I need to process a xml file, in which a certain text has to be inserted (duplicated) - see the following, for an example:
<Item Property1="..." ... PropertyN="someText"></Item>
How I want it to look:
<Item Property1="..." ... PropertyN="someText">someText</Item>
The someText
- doesn't have a fixed length (1 or more sentences/words)
- can/may contain the followings:
- &# xD; &# xA
- (& amp; and _)
- {0}{1}
- /\~!@#%&*_+
My questions:
I've managed to find some of the groups (i.e. the text before PropertyN (
^.*?PropertyN="
) and the last group (i.e the one containing "> < /Item>" -\"></Item>.*$
)) but I don't know how to extract the PropertyN value, how to integrate it and how to duplicate it.How can I change the (replace with) regex so that a prefix and/or a suffix (constant in the entire file) are added for each copy of the someText? (for example I want "###prefix" and "###suffix" to be added so that the line looks like this)
<Item Property1="..." ... PropertyN="someText">###prefixsomeText###suffix</Item>
Thank you!
R