Regex matching 3rd word in a line?

Klaus-G. Meyer kmey at despammed.com
Fri Oct 31 06:43:19 EST 2003


Ian Gil wrote:
> and I'm looking to match just the third word.

Hm, first extract the third word and then use re?

 >>> s = "one two three four"
 >>> s.split()[2]
'three'

split has an optional argument "sep" to define other chars than 
whitespace characters.

-- 
Gruß - regards
Klaus :-)





More information about the Python-list mailing list