Replace text at the first of the specific lines? Sigil or Notepad++ Regex

1

How can I replace text at the first of specific lines

Example before:

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

And i want to be like this

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

Is there a way to do it in selected text area maybe with regex?

Aris Munandar

Posted 2018-12-03T09:12:57.667

Reputation: 13

1To be clear, you want to remove the at the beginning of each line and suround all lines with quotes? – Toto – 2018-12-03T09:58:32.297

Answers

1

  • Ctrl+H
  • Find what: (?<=<p>)– (.+)(?=</p>)
  • Replace with: "$1"
  • check Wrap around
  • check Regular expression
  • UNCHECK . matches newline
  • Replace all

Explanation:

(?<=<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

Replacement:

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

Result for given example:

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

Toto

Posted 2018-12-03T09:12:57.667

Reputation: 7 722

Thank you, it's work on notepad++, but on sigil ( html) it's not work

here example text

<p>– Your mother created a song?</p>

<p>– She was a pianist.</p>

<p>– Okay then, let us hear the song.</p>

and i want like this

<p>"Your mother created a song?</p>

<p>"She was a pianist.</p>

<p>"Okay then, let us hear the song."</p> – Aris Munandar – 2018-12-03T11:16:03.797

@ArisMunandar: You've ask for a regex for Notepad++ or Sigil. I don't know sigil, may it doesn't understand regex. – Toto – 2018-12-03T11:21:55.727

sigil is like ebook (epub) editor, where you can edit ebook using html. but it's okay now, it's worked while trying your code and with little edit.

Thank you! – Aris Munandar – 2018-12-03T11:27:50.203

@ArisMunandar: I have updated the answer to deal with <p> tags. – Toto – 2018-12-03T11:29:35.527