Python - Regular Expressions
Revision as of 14:53, 21 April 2008 by PeterHarding (talk | contribs) (New page: =Using the re Module= <pre> #!/usr/bin/env python #-------------------------------------------------------------------------- import re ... if re.match('esb:', node_name): (na...)
Using the re Module
#!/usr/bin/env python
#--------------------------------------------------------------------------
import re
...
if re.match('esb:', node_name):
(name, cnt) = re.subn('esb:', '', node_name)
setattr(service, name, value)
print "service.__dict__ -> '%s'" % service.__dict__
return
if re.match('ns0:', node_name):
(name, cnt) = re.subn('ns0:', '', node_name)