def re(self, irc, msg, args, ff, text): """<regexp> <text> If <regexp> is of the form m/regexp/flags, returns the portion of <text> that matches the regexp. If <regexp> is of the form s/regexp/replacement/flags, returns the result of applying such a regexp to <text> """ if isinstance(ff, (types.FunctionType, types.MethodType)): f = ff else: f = lambda s: ff.search(s) and ff.search(s).group(0) or '' if f('') and len(f(' ')) > len(f(''))+1: # Matches the empty string. s = 'You probably don\'t want to match the empty string.' irc.error(s) else: irc.reply(f(text)) re = wrap(re, [('checkCapability', 'trusted'), first('regexpMatcher', 'regexpReplacer'), 'text'])