Regex
Sep20Difficulty: 




Last week I had to convert an excel sheet to the XML format. Okay that’s an easy one, was what I was thinking cause with Microsoft Office you can export to XML. Never the less, the rendered output looked dirty. Same XML namespaces but different ids. That was totally different then what I needed for my just created Flash program. My peace of software can only read clean XML code.
You probably will understand that I was not happy with the idea, that I had to take the excel sheet over by hand. And since I’m lazy (~all programmers are!~) it found an idea which could spare me a lot of time.
The solution is easy. Use regex. – With a text editor (I used PSPad) and some regular expressions, you can easily generate from a dirty MS Office XML to your own clean XML markup. Just do a Find and Replace All:
//FIND: <TAG>(.+?)</TAG> //REPLACE: <YOURTAG>$1</YOURTAG>
» Post your comment, there are no comments yet. »Posted in regex |
Comments