替換特定行第一行的文字? Sigil 或 Notepad++ 正規表示式

替換特定行第一行的文字? Sigil 或 Notepad++ 正規表示式

如何替換特定行第一行的文本

之前的例子:

<p>– Your mother created a song?</p>
<p>– She was a pianist.</p>
<p>– Okay then, let us hear the song.</p>

我想成為這樣

<p>"Your mother created a song?"
<p>"She was a pianist."</p>
<p>"Okay then, let us hear the song."</p>

有沒有辦法在選定的文字區域中使用正規表示式來做到這一點?

答案1

  • Ctrl+H
  • 找什麼:(?<=<p>)– (.+)(?=</p>)
  • 用。"$1"
  • 檢查環繞
  • 檢查正規表示式
  • 取消選取. matches newline
  • Replace all

解釋:

(?<=<p>)    # positive lookbehind, make sure we have <p> before
    –       # – character followed by a space
    (.+)    # group 1, any character nut newline
(?=</p>)    # positive lookahead, make sure we have </p> after

替代品:

"   # a double quote
$1  # content of group 1, the sentence
"   # a double quote

給定範例的結果:

<p>"Your mother created a song?"</p>
<p>"She was a pianist."</p>
<p>"Okay then, let us hear the song."</p>

相關內容