forked from aichaos/rivescript-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathregexp.py
More file actions
47 lines (44 loc) · 1.85 KB
/
Copy pathregexp.py
File metadata and controls
47 lines (44 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# RiveScript-Python
#
# This code is released under the MIT License.
# See the "LICENSE" file for more information.
#
# https://www.rivescript.com/
from __future__ import unicode_literals
import re
"""Common regular expressions used in RiveScript."""
# Common regular expressions.
class RE(object):
equals = re.compile('\s*=\s*')
ws = re.compile('\s+')
objend = re.compile('^\s*<\s*object')
weight = re.compile('\{weight=(\d+)\}')
inherit = re.compile('\{inherits=(\d+)\}')
wilds = re.compile('[\s\*\#\_]+')
nasties = re.compile('[^A-Za-z0-9 ]')
crlf = re.compile('<crlf>')
literal_w = re.compile(r'\\w')
array = re.compile(r'\@(.+?)\b')
def_syntax = re.compile(r'^.+(?:\s+.+|)\s*=\s*.+?$')
name_syntax = re.compile(r'[^a-z0-9_\-\s]')
utf8_trig = re.compile(r'[A-Z\\.]')
trig_syntax = re.compile(r'[^a-z0-9(\|)\[\]*_#@{}<>=\s]')
cond_syntax = re.compile(r'^.+?\s*(?:==|eq|!=|ne|<>|<|<=|>|>=)\s*.+?=>.+?$')
utf8_meta = re.compile(r'[\\<>]')
utf8_punct = re.compile(r'[.?,!;:@#$%^&*()]')
cond_split = re.compile(r'\s*=>\s*')
cond_parse = re.compile(r'^(.+?)\s+(==|eq|!=|ne|<>|<|<=|>|>=)\s+(.+?)$')
topic_tag = re.compile(r'\{topic=(.+?)\}')
set_tag = re.compile(r'<set (.+?)=(.+?)>')
bot_tag = re.compile(r'<bot (.+?)>')
get_tag = re.compile(r'<get (.+?)>')
star_tags = re.compile(r'<star(\d+)>')
botstars = re.compile(r'<botstar(\d+)>')
input_tags = re.compile(r'<input([1-9])>')
reply_tags = re.compile(r'<reply([1-9])>')
random_tags = re.compile(r'\{random\}(.+?)\{/random\}')
redir_tag = re.compile(r'\{@(.+?)\}')
tag_search = re.compile(r'<([^<]+?)>')
placeholder = re.compile(r'\x00(\d+)\x00')
zero_star = re.compile(r'^\*$')
optionals = re.compile(r'\[(.+?)\]')