fork download
  1. # http://stackoverflow.com/q/32861718/5290909
  2. import re
  3.  
  4. text = '''
  5. <modules>
  6. <Orba_Sheepla>
  7. <!-- module version -->
  8. <version>0.9.25</version>
  9. </Orba_Sheepla>
  10. </modules>'''
  11.  
  12. pattern = re.compile( r'^([ \t]+)<version>.*?^(?!\1)[ \t]*</([^\s>]+)', re.I | re.S | re.M)
  13. match = pattern.search(text)
  14.  
  15. if match:
  16. print(match.group(2))
Success #stdin #stdout 0.03s 9984KB
stdin
Standard input is empty
stdout
Orba_Sheepla