新しい正規表現モジュールのファジー機能を試しています。この場合、エラーが 1 以下のすべての文字列の一致を見つけたいのですが、問題が発生しています。
import regex
statement = 'eol the dark elf'
test_1 = 'the dark'
test_2 = 'the darc'
test_3 = 'the black'
print regex.search('{}'.format(test_1),statement).group(0) #works
>>> 'the dark'
print regex.search('{}'.format(test_1){e<=1},statement).group(0)
>>> print regex.search('{}'.format(test_1){e<=1},statement).group(0) #doesn't work
^
SyntaxError: invalid syntax
私も試してみました
print regex.search('(?:drk){e<=1}',statement).group(0) #works
>>> 'dark'
でもこれは 。. .
print regex.search(('(?:{}){e<=1}'.format(test_1)),statement).group(0) #doesn't work
>>> SyntaxError: invalid syntax