Find the longest element from the list, matching a string

This is the place for queries that don't fit in any of the other categories.

Find the longest element from the list, matching a string

Postby vedika9009 » Sun Jun 15, 2014 3:46 am

Code: Select all
>>> aa
('foo.com', 'bar.com', 'foobar.com')
>>> for i in aa:
...      match = re.search('bar.com',i)
...
>>> match.group()
'bar.com'


Instead of 'bar.com' I want the longest item 'foobar.com'
Is that possible ?
vedika9009
 
Posts: 7
Joined: Mon Jun 09, 2014 7:47 pm

Return to General Coding Help

Who is online

Users browsing this forum: Mekire, monk and 2 guests