print("Hello World!")
regexp = "^\d[a-z]+"
string = "^123hello"
class Meta:
"""
匹配所用最小单元/min unit for match
"""
class Type:
start = 0x01
end = 0x02
escap = 0x03
digit = 0x04
border = 0x05
lower = 0x06
upper = 0x07
word = 0x08
list = 0x09
number = 0x10 # {0,5} * + ?
def __init__(self, type, chars, num, backend, forcast):
self.type = type
self.chars = chars
self.num = num
self.backend = backend
self.forcast = forcast
def __str__(self):
print( backend, chars, num, forcast)
def convert2MetaList(regexp):
meta_list = []
regexp_len = len(regexp)
for i in range(regexp_len):
char = regexp[i]
if char == "^":
meta = Meta(Meta.Type.start, char)
elif char == "$":
meta = Meta(Meta.Type.end, char)
else:
pass
meta_list.apppend(meta)
return meta_list
def match(string, meta_list):
pass
def main(regexp, string):
# regexp covert
meta_list = convert2MetaList(regexp)
print(meat_list)
# match
# ret = match(string, meta_list)
# print(ret)
main(regexp, string)