h/plugins/regular.py

24 lines
427 B
Python
Raw Normal View History

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