Answers.Body: <p>Sigil's regex engine is kind of fussy; I'm not sure that the anonymous answer above would work.</p>
  
  <p>I answered this <a href="https://www.quora.com/How-do-I-join-broken-Paragraphs-from-an-ePub-using-Regex-on-Sigil/answer/David-Kudler" rel="nofollow">on Quora</a>, but I'll post the answer again here, because it seems like that would be helpful:</p>
  
  <blockquote>
    <p>Ah. Let me guess. You're converting from a PDF. You have my sympathy. :-)</p>
    
    <p>I've done this. Here's the search expression I used:</p>
  </blockquote>
  
  <pre><code>([a-z]|,|;)&lt;/p&gt;\s+&lt;p&gt;
  </code></pre>
  
  <blockquote>
    <p>That found paragraphs that ended without a period, exclamation point, question mark, or right double quotes. (Since I'm assuming you're working from a PDF of a print document, I didn't include in the query all of the other possible marks, since, for instance, a left double quotation mark is extremely unlikely to come at the end of a text line.)</p>
    
    <p>The replace expression was simply this:</p>
  </blockquote>
  
  <pre><code>\1 
  </code></pre>
  
  <blockquote>
    <p>Note that there's a space after the wildcard, so that you don't end up smooshing words together. </p>
    
    <p>That should get rid of the unwanted paragraph breaks and splice your text together properly.</p>
    
    <p>Unfortunately, if you've got letters reproduced in the book or some other text format that has paragraphs ending in commas, semicolons, or lower case letters, you'll have to do Replace/Find and go case by case rather than Replace All.</p>
  </blockquote>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-01-12T18:40:39.767Z
Answers.Text: The code David Kudler described above on October 2, 2015 has cleaned up hundreds of whitespace problems in ebooks I have been formatting. I love it. But when I stored the code in a folder in OneNote and then pasted it to a new ebook, it stopped working. This was extremely annoying. Perhaps OneNote added some dirty html or whatever. I now store in the code in Notepad++ which has proved to be a better home. It cleans up whitespaces when pasted in from Notepad**. Thanks for contributing the code, David.
Answers.UserDisplayName: JimM
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-02T04:16:50.140Z
Answers.LastActivityDate: 2015-10-02T04:16:50.140Z
Answers.UserDisplayName: David Kudler
Answers.Body: <p>This worked and you can play with it if you want. Please copy it before changing it. <a href="https://regex101.com/r/gO0zG0/1" rel="nofollow">https://regex101.com/r/gO0zG0/1</a>. </p>
  
  <p>A regex replace is like this in Perl: <code>$s=~s/OLDPATTERN/NEWPATTERN/g;</code></p>
  
  <p>The regex was: <code>/&lt;\/p&gt;\n\n&lt;p&gt;//g;</code></p>
  
  <p>Replace the first part between the first two <code>//</code> with nothing. The <code>\n</code> SHOULD be properly initialized by the regex engine for your operating system (you shouldn't have to do a thing),  because it has different values for different OSes. But if that <code>\n</code> doesn't work, please let me know. You might have to try <code>\l\r</code> or <code>\r\l</code>. </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-06-28T14:35:28.947Z
Answers.LastActivityDate: 2016-06-28T14:35:28.947Z
Answers.UserDisplayName: Bulrush
Body: <p>I'm trying to edit some xhtml on Sigil.</p>
  
  <p>With the command <code>"&lt;p&gt;([a-z])</code> I'm able to find all paragraphs that begin with lower case. That tells me that they shouldn't be separate from the previous one. It's just a conversion issue.</p>
  
  <p>What should I do to delete both the &lt; p> from that paragraph and the <code>&lt;/p&gt;</code> from the previous one in order to join the two blocks of text into one single paragraph??</p>
  
  <p>It looks something like this:</p>
  
  <pre><code>&lt;p&gt; ... that is why relationships&lt;/p&gt;
  
  &lt;p&gt; are not what they should be.
  </code></pre>
  
  <p>And it should be:</p>
  
  <pre><code>&lt;p&gt; that is why relationships are not what they should be.&lt;/p&gt;
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-09-26T12:34:07.227Z
Comments.Text: I miss Sigil. I wish it were still being developed.
Comments.UserDisplayName: Paulb
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-06-28T14:37:59.323Z
Comments.Text: What OS are you running Sigil on? Windows?
Comments.UserDisplayName: Bulrush
Tags: <epub><html><sigil>
Title: Join broken paragraphs Regex Sigil
UserDisplayName: Rondo
ThreadText: # Join broken paragraphs Regex Sigil
  
  (Asked by: username_0 on 2015-09-19)
  
  I'm trying to edit some xhtml on Sigil.
  
  With the command `"<p>([a-z])` I'm able to find all paragraphs that begin with lower case. That tells me that they shouldn't be separate from the previous one. It's just a conversion issue.
  
  What should I do to delete both the < p> from that paragraph and the `</p>` from the previous one in order to join the two blocks of text into one single paragraph??
  
  It looks something like this:
  
  ```
  <p> ... that is why relationships</p>
  
  <p> are not what they should be.
  
  ```
  
  And it should be:
  
  ```
  <p> that is why relationships are not what they should be.</p>
  
  ```
  
  **Tags:** epub, html, sigil
  
  > **Comments:**
  > **username_1**: I miss Sigil. I wish it were still being developed.  
  > **username_2**: What OS are you running Sigil on? Windows?  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_3 on 2015-10-02. Score: 1
  
  Sigil's regex engine is kind of fussy; I'm not sure that the anonymous answer above would work.
  
  I answered this [on Quora](https://www.quora.com/How-do-I-join-broken-Paragraphs-from-an-ePub-using-Regex-on-Sigil/answer/username_3), but I'll post the answer again here, because it seems like that would be helpful:
  
  > Ah. Let me guess. You're converting from a PDF. You have my sympathy. :-)
  >
  > I've done this. Here's the search expression I used:
  
  ```
  ([a-z]|,|;)</p>\s+<p>
  
  ```
  
  > That found paragraphs that ended without a period, exclamation point, question mark, or right double quotes. (Since I'm assuming you're working from a PDF of a print document, I didn't include in the query all of the other possible marks, since, for instance, a left double quotation mark is extremely unlikely to come at the end of a text line.)
  >
  > The replace expression was simply this:
  
  ```
  \1 
  
  ```
  
  > Note that there's a space after the wildcard, so that you don't end up smooshing words together.
  >
  > That should get rid of the unwanted paragraph breaks and splice your text together properly.
  >
  > Unfortunately, if you've got letters reproduced in the book or some other text format that has paragraphs ending in commas, semicolons, or lower case letters, you'll have to do Replace/Find and go case by case rather than Replace All.
  
  > **Comments:**
  > **username_4**: The code username_3 username_3 described above on October 2, 2015 has cleaned up hundreds of whitespace problems in ebooks I have been formatting. I love it. But when I stored the code in a folder in OneNote and then pasted it to a new ebook, it stopped working. This was extremely annoying. Perhaps OneNote added some dirty html or whatever. I now store in the code in Notepad++ which has proved to be a better home. It cleans up whitespaces when pasted in from Notepad**. Thanks for contributing the code, username_3.  
  
  ---
  
  ### Answer by username_2 on 2016-06-28. Score: 0
  
  This worked and you can play with it if you want. Please copy it before changing it. <https://regex101.com/r/gO0zG0/1>.
  
  A regex replace is like this in Perl: `$s=~s/OLDPATTERN/NEWPATTERN/g;`
  
  The regex was: `/<\/p>\n\n<p>//g;`
  
  Replace the first part between the first two `//` with nothing. The `\n` SHOULD be properly initialized by the regex engine for your operating system (you shouldn't have to do a thing), because it has different values for different OSes. But if that `\n` doesn't work, please let me know. You might have to try `\l\r` or `\r\l`.
  
  
  ---
  
  