Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

Test whether an SGML attribute value requires quoting (See related posts)

SGML attribute values don't always need to be quoted; here's a quick bit of Python which returns whether an attribute value needs to be quoted or not:

import re
if re.compile('^[a-zA-Z0-9_\-\.:]+$').search(value):
   ...does not need quoting..
else:
   ...does need quoting...

You need to create an account or log in to post comments to this site.


Related Posts