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.
正規表現が終了タグの前に改行を追加するのはなぜですか?
string = '\s ప్రపంచ ప్రారంభం' re.sub(r'\\s (.*)', r'<h3>\1</h3>', string)
私が得るもの
<h3>ప్రపంచ ప్రారంభం </h3>
私が欲しいもの
<h3>ప్రపంచ ప్రారంభం</h3>
文字列のテキスト部分を見て、改行を作成しているものがないことを確認してください。私が試したとき:
s = '\s hi world' re.sub(r'\\s (.*)', r'<h3>\1</h3>', s)
私が得た:
'<h3>hi world</h3>'
私はPython 2.7.3を使用していました。