On Sun, 2006-06-04 at 06:26 +0000, Marc Schoechlin wrote: > Hi ! > > Nexu <[EMAIL PROTECTED]> schrieb: > > I'm trying to write a def to match a string that is an irc hostmask. eg: > > [EMAIL PROTECTED] > > But using re.search(). I get an error when the string starts with '*'. > > What is the best way to solve this? > > I suppose the problem occurs because you expression is not a valid > regular expression. > > A correct regular expression should look like this: > "[EMAIL PROTECTED]" Thx for everyones input.
This solved the problem: host = '[EMAIL PROTECTED]' mask = '[EMAIL PROTECTED]' newmask = re.sub('\*', '.*', re.sub('\?', '.', mask)) result in that: re.search(newmask, host) == True -- http://mail.python.org/mailman/listinfo/python-list