Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
テキストから削除するには、どの文字の前に「\」が必要ですか? このような :
import re my_source = re.sub('\(','',my_source)
特殊文字 ( .、?、(、)...) は、文字どおりに一致するようにエスケープする必要があります。
.
?
(
)
ここから特殊文字を見つけることができます- 正規表現の構文。
しかし、自分でやる必要はありません。使用できますre.escape:
re.escape
>>> import re >>> re.escape('(') '\\(' >>> print(re.escape('(')) \(