I have some txt-files made from pdfs and want so add some xml-tags using a little python-script and regex-patterns. Mostly it works fine but sometimes an expression matches not all the characters wanted. In the testing tool here it works right.
Here's the python-code:
matchs = re.finditer("<UTop>[^<]+",string)
for m in matchs:
tagend = m.end()
string = string[:tagend] + "</UTop>" + string[tagend:]
The original string...
<Top>1. Regierungserklärung des Ministerpräsidenten<UTop>Ministerpräsident Winfried Kretschmann </Top>
... should be transformed to:
<Top>1. Regierungserklärung des Ministerpräsidenten<UTop>Ministerpräsident Winfried Kretschmann </UTop></Top>
but it returns
<Top>1. Regierungserklärung des Ministerpräsidenten<UTop>Ministerpräsident Winfried Krets</UTop>chmann </Top>
instead.
I would be glad to get a reply to that question. Jan