我正在尝试在 python 中匹配方括号(使用字符类)。但是下面的代码不成功。有谁知道正确的方法是什么?
#!/usr/bin/env python
import re
prog = re.compile('[\[]+')
print prog.match('a[f')
prog = re.compile('[\]]+')
print prog.match('a]f')
我正在尝试在 python 中匹配方括号(使用字符类)。但是下面的代码不成功。有谁知道正确的方法是什么?
#!/usr/bin/env python
import re
prog = re.compile('[\[]+')
print prog.match('a[f')
prog = re.compile('[\]]+')
print prog.match('a]f')