Python正则表达式在字节字符串上返回none

时间:2017-05-26 10:47:38

标签: python regex string

我正在尝试对字节字符串进行RE.match,并且由于某种原因没有返回。

我的字符串来自一个ssh会话,我指向var输出

output = connection..recv(65535)

如果我打印这个字符串它显示一个前导b“,所以我使用de decode函数以易于阅读的格式打印它

strg = output.decode()

我的问题是,当我对var(输出或字符串)执行re.match时,我没有得到macth,如果我在Rexgex101上练习RegEx,我得到一个匹配。

输出变量here

用于strg var here

我的python正则表达式如下:

if re.match(r'\|(.*)\|default',strg):
    print("match found")

if re.match(r'\r\\n\|(\d{1,})\s{1,}\|default\s{1,}[^45]',str(output)):
    print("match found")

为什么没有得到匹配的任何想法,我做错了什么?

0 个答案:

没有答案
相关问题