How to write Regex for extracting tags?

I want to extract all tags in a xml file. However, I cannot write proper regular expression to extract the content I want.

The tags format in the file is like :

 Tags=<"tracffic""apple""sample">

And I want to return a list contained all the tags: [traffic, apple, sample]

I tried this:

    Tags=<("[\w]+")+

which only return the last tag.

Could anyone give me a hand?

Answers


Try this:

m = re.search('<(".+")>', 'Tags=<"traffic""apple""sample">')
tags = [x for x in m.group(1).split('"') if x]

Now tags contains:

['traffic', 'apple', 'sample']

Need Your Help

key value routing in Zend Framework Route

php zend-framework router routes hostname

I'm using a Hostname route to capture a subdomain and use as a category. I then chain a Router route for the controller, action and key/value pairs.

User's Facebook Status to tableview

ios xcode facebook uitableview

I am newbie to Facebook app development, and have done some research but cant seem to find what I am looking for. Here's what I am trying to do.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.