h/plugins/regular.py

25 lines
435 B
Python
Raw Normal View History

2010-01-26 04:39:26 +00:00
'''
regular.py
skybot plugin for testing regular expressions
by Ipsum
'''
import re
from util import hook
2010-01-26 22:57:47 +00:00
@hook.command('re')
2010-02-02 04:42:34 +00:00
def reg(inp):
".re <regex> <string> -- matches regular expression in given <string> "\
"(leave 2 spaces between)"
query = inp.split(" ", 1)
if not inp or len(query) != 2:
return reg.__doc__
return '|'.join(re.findall(query[0], query[1]))