替换特定行的第一行的文本?Sigil 或 Notepad++ Regex

替换特定行的第一行的文本?Sigil 或 Notepad++ Regex

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

之前的例子:

<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>

相关内容