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.
正規表現を使用して、複数行の文字列からすべての空白文字を削除したいと考えています。私が探しているのは次のようなものです:
exp = re.compile("\s-[\r\n]") exp.sub('', text)
上記を行う正規表現はありますか。は Unicode であるため、以外のクラスtextを形成できる他の文字の可能性があるため、 は使用できません。\s[\t\v\f \r\n][\t\v\f ]
text
\s
[\t\v\f \r\n]
[\t\v\f ]
次の二重否定文字クラスを試してください。
[^\S\r\n]
例: http://rubular.com/r/t2Ahjs9UzF