[Tutor] Comparing a string

Alan G alan.gauld at freenet.co.uk
Sat May 21 00:58:03 CEST 2005


> I'm tryin compare a string with a value with style of
pattern-matching.
>
> string = 'i686'
>
> if string == glob.glob(i?86):

Use regular expressions and turn it around:

import re
s = 'i686'
ex = re.compile('i?86')
if ex.match(s): print 'they match!'

Is that what you mean?

Alan G.



More information about the Tutor mailing list