2008-06-24 14:45:33
Simple XML End-Tag Detection
Say you're working with an XML or RDF document and your program keeps spitting out errors saying that some tags aren't closed, etc. What do you do if you don't have an XML validator installed and your data is too sensitive to upload to an online validator? As long as you don't have records broken onto multiple lines, you can use a simple regex to search for any line that doesn't end with a >, which is the closing character of a tag.Most editors allow searching using regular expressions. All you have to is search for this pattern:
[^>]$
This will take you to every line where the > character isn't the last character of the line. Simple... yes. Doesn't work in all situations... sure. But it's a nice regex nugget to keep in your toolbox.Back