这是我的代码:
#!/usr/bin/python
import io
import re
f = open('/etc/ssh/sshd_config','r')
strings = re.search(r'.*IgnoreR.*', f.read())
print(strings)
那返回数据,但是我需要特定的正则表达式匹配:例如:
^\s*[^#]*IgnoreRhosts\s+yes
如果我将代码更改为简单:
strings = re.search(r'^IgnoreR.*', f.read())
甚至
strings = re.search(r'^.*IgnoreR.*', f.read())
我什么也没拿回来。我需要能够在Perl中使用真正的正则表达式
不负相思意
相关分类