_calcRe = re.compile(r'(.*?)', re.I) _calcSupRe = re.compile(r'(.*?)', re.I) _calcFontRe = re.compile(r'(.*?)') _calcTimesRe = re.compile(r'&(?:times|#215);') def calc(self, irc, msg, args, expr): """ Uses Google's calculator to calculate the value of . """ url = self._googleUrl(expr) html = utils.web.getUrl(url) match = self._calcRe.search(html) if match is not None: s = match.group(1) s = self._calcSupRe.sub(r'^(\1)', s) s = self._calcFontRe.sub(r',', s) s = self._calcTimesRe.sub(r'*', s) irc.reply(s) else: irc.reply('Google\'s calculator didn\'t come up with anything.') calc = wrap(calc, ['text'])