Oct-22-2019, 07:30 AM
(Oct-22-2019, 06:53 AM)evilcode1 Wrote: i have this string :
Quote:<?xml version="1.0" encoding="utf-8"?>i need to search for <version> then print just ( 3.6.0 ) , how i can do that ?
<metafile version="3.6" client="site">
<name>English (en-GB)</name>
<version>3.6.0</version>
<creationDate>July 2016</creationDate>
<author>Joomla! Project</author>
[ ... ]
Hi!
Maybe you could use something like:
import re string1 = '''<?xml version="1.0" encoding="utf-8"?> <metafile version="3.6" client="site"> <name>English (en-GB)</name> <version>3.6.0</version> <creationDate>July 2016</creationDate> <author>Joomla! Project</author> [ ... ]''' requirement1 = re.search('<version>(.*)</version>', string1) print(requirement1.group(1))that produces the following output:
Output:3.6.0
All the best,
newbieAuggie2019
"That's been one of my mantras - focus and simplicity. Simple can be harder than complex: You have to work hard to get your thinking clean to make it simple. But it's worth it in the end because once you get there, you can move mountains."
Steve Jobs
"That's been one of my mantras - focus and simplicity. Simple can be harder than complex: You have to work hard to get your thinking clean to make it simple. But it's worth it in the end because once you get there, you can move mountains."
Steve Jobs