Open BRIDGE-AI opened 3 months ago
pyVoIP/regex.py
에서 아래의 2개 패턴에 대해TO_FROM_MATCH = re.compile(
r'(?P<display_name>"?[\w ]*"? )?<?(?P<uri_type>sips?):(?P<user>[\w+]+)(?P<password>:\w+)?@(?P<host>[\w.]+)(?P<port>:[0-9]+)?>?'
)
TO_FROM_DIRECT_MATCH = re.compile(
r'(?P<display_name>"?[\w ]*"? )?<?(?P<uri_type>sips?):(?P<host>[\w.]+)(?P<port>:[0-9]+)?>?'
)
r'(?P<display_name>"?[\w ]*"? )?<?(?P<uri_type>sips?):(?P<user>[\w+]+)(?P<password>:\w+)?@(?P<host>[\w.]+)(?P<port>:[0-9]+)?>?'
display_name 뒤에 항상 공백 하나가 있어야 되도록 패턴 정의됨
import re
#TO_FROM_MATCH = re.compile(
# r'(?P<display_name>"?[\w ]*"? )?<?(?P<uri_type>sips?):(?P<user>[\w+]+)(?P<password>:\w+)?@(?P<host>[\w.]+)(?P<port>:[0-9]+)?>?'
#)
TO_FROM_MATCH = re.compile(
r'(?P<display_name>"?[\w ]*"?[ ]*)?<?(?P<uri_type>sips?):(?P<user>[\w+]+)(?P<password>:\w+)?@(?P<host>[\w.]+)(?P<port>:[0-9]+)?>?'
)
data = "\"sipvicious\"<sip:100@1.1.1.1>"
reg = TO_FROM_MATCH
match = reg.match(data)
print(f"match:{match}")
TO_FROM_MATCH = re.compile(
r'(?P<display_name>"?[\w ]*"?[ ]*)?<?(?P<uri_type>sips?):(?P<user>[\w+]+)(?P<password>:\w+)?@(?P<host>[\w.]+)(?P<port>:[0-9]+)?>?'
)
TO_FROM_DIRECT_MATCH = re.compile(
r'(?P<display_name>"?[\w ]*"?[ ]*)?<?(?P<uri_type>sips?):(?P<host>[\w.]+)(?P<port>:[0-9]+)?>?'
)
display_name 뒤에 공백이 없거나 1개 또는 여러개 있을 수 있는 형태로 수정
brief.