 <p>Regex can't parse XML and shouldn't be used to parse <em>fake</em> XML. You should do one of</p> <ul> <li>Use a serialization method that is nicer to work with to start with, such as JSON or an ini file with the <code>ConfigParser</code> module.</li> <li><em>Really use XML</em> and not something that just sort of looks like XML and <em>really parse it</em> with something like <code>lxml.etree</code>.</li> <li>Just store the number in a file if this is the entirety of your configuration. This solution isn't really easier than just using JSON or something, but it's better than the current one.</li> </ul> <p>Implementing a bad solution now for future needs that you have no way of defining or accurately predicting is always a bad approach. You will be kept busy enough trying to write and maintain software <em>now</em> that there is no good reason to try to satisfy unknown future needs. I have never seen a case where "I'll put this in for later" has led to less headache later on, especially when I put it in by doing something completely wrong. YAGNI!</p> <p>As to what's wrong with your snippet other than using an entirely wrong approach, angled brackets have a meaning in regex.</p>