実現したいこと
いままで問題なく動いていたプログラムがPython3.11にしたところうまく動かなくなってしまいました。
調べたところ3.11では正規表現の書き方に変更があったようなのですが、どこを直せばよいのかわかりません。
ご教示のほどよろしくお願いいたします
発生している問題・エラーメッセージ
Traceback (most recent call last): File "/home//Documents/selenium/aaa.py", line 177, in getpasscode passcode_txt = re.sub(r'\d{4,6}yen|\d{4,6}(?i)pon|http.*? ', " ", code) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/re/__init__.py", line 185, in sub return _compile(pattern, flags).sub(repl, string, count) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/re/__init__.py", line 294, in _compile p = _compiler.compile(pattern, flags) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/re/_compiler.py", line 743, in compile p = _parser.parse(p, flags) ^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/re/_parser.py", line 980, in parse p = _parse_sub(source, state, flags & SRE_FLAG_VERBOSE, 0) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/re/_parser.py", line 455, in _parse_sub itemsappend(_parse(source, state, verbose, nested + 1, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/re/_parser.py", line 841, in _parse raise source.error('global flags not at the start ' re.error: global flags not at the start of the expression at position 16
該当のソースコード
Python
1code = re.sub(r'\d{4,6}yen|\d{4,6}(?i)pon|http.*? ', " ", code )
re.sub(r'\d{4,6}yen|\d{4,6}(?i:pon)|http.*? ', " ", ...)
回答1件
あなたの回答
tips
プレビュー