This appears to be what Text->Remove Line Breaks does in a single click.

But how's this for shorter and sweeter grep-ness. 

In grep mode, search for:
[^$]\n
or shorter yet:
.\n

Either one seems to find newlines at the end of text, but not on a line by 
themselves. Replacing with a space finishes the task.

But will Text->Remove Line Breaks do the job?

On Wednesday, May 31, 2023 at 11:27:27 AM UTC-5 Neil Faiman wrote:

>
> On May 30, 2023, at 10:47 PM, ProjectGuru <xav...@visual2go.com> wrote:
>
> I'm looking for a GREP pattern that can delete the newlines that exist 
> ONLY after some text and NOT newline characters that exist between 
> paragraphs For example:
>
> =================================================
>
> ORIGINAL TEXT:
>
> [Ms. Rowling] This is Ms.
> Rowling, author
> of the Harry Potter
> collection.
> And now onto the show.
>
> [intro music]
>
> [John] Hi everyone.
> Welcome back to the
> Harry Potter podcast.
> I'm your co-host John Doe.
>
> DESIRED RESULT:
>
> [Ms. Rowling] This is Ms. Rowling, author of the Harry Potter collection. 
> And now onto the show.
>
> [intro music]
>
> [John] Hi everyone. Welcome back to the Harry Potter podcast. I'm your 
> co-host John Doe.
>
> =================================================
>
>
> This search pattern will do the trick.
>
> (?s)(?<=\S)\n(?=\S)
>
>
> Command-F; put it in the Find: box, put a single space in the Replace: 
> box, check Grep, and click Replace All.
>
> Explanation:
>
>
>    - (?s) — the string being searched is the entire document, not 
>    individual lines.
>    - (?<=\S)) — match the search string only when it is preceded by a 
>    non-white-space character
>    - \n — the actual search string: a single newline
>    - (?=\S) — match the search string only when it is followed by a 
>    non-white-space character
>
>
> When I apply this to your original text, I get:
>
> [Ms. Rowling] This is Ms. Rowling, author of the Harry Potter collection. 
> And now onto the show.
>
>
> [intro music]
>
>
> [John] Hi everyone. Welcome back to the Harry Potter podcast. I'm your 
> co-host John Doe.
>
> Cheers,
> Neil Faiman
>
>

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "supp...@barebones.com" rather than 
posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/9687fb7b-d116-487d-a626-24af14c25cffn%40googlegroups.com.

Reply via email to