所以我有一個yaml文件,我將其用作配置文件。我試圖做一些字符串與正則表達式匹配,但我無法解釋從yaml到Python的正則表達式。有問題的正則表達式如下:Python從yaml配置文件解釋正則表達式
regex:
- [A-Za-z0-9]
當我嘗試使用re.match功能,我得到這個錯誤:
Traceback (most recent call last):
File "./dirpylint.py", line 132, in <module>
sys.exit(main())
File "./dirpylint.py", line 32, in main
LevelScan(level)
File "./dirpylint.py", line 50, in LevelScan
regex_match(level)
File "./dirpylint.py", line 65, in regex_match
if re.match(expression, item) == None:
File "/usr/lib/python2.7/re.py", line 137, in match
return _compile(pattern, flags).match(string)
File "/usr/lib/python2.7/re.py", line 229, in _compile
p = _cache.get(cachekey)
TypeError: unhashable type: 'list'
我的理解,它的解釋正則表達式作爲一個列表,但如何使用yaml文件中定義的正則表達式來搜索字符串?