Remove space before a sentence with words

89 views
Skip to first unread message

Otto Munters

unread,
Jul 26, 2024, 7:39:05 AM7/26/24
to BBEdit Talk
Hi BB friends
How do I remove a empty space before a sentence with words?
Thanks for your help!


Ulrich Kapp

unread,
Jul 26, 2024, 10:17:13 AM7/26/24
to BBEdit Talk
Hi Otto,

use Grep option in search and

(^)(\W)(.*$)


as search pattern and

\1\3


as replacement pattern

That will help.

Otherwise it will help to play around with the Pattern Playground in BBEdit to find a solution.

Best wishes, Ulrich

Otto Munters

unread,
Jul 29, 2024, 9:00:02 AM7/29/24
to BBEdit Talk
Hi Ulrich
Thank you for your reply. This Grep also removes the empty lines. How can I avoid that?
Here is an example:

166
00:09:51,690 --> 00:09:55,510
And then this entire thing is
nothing but wood, right?

167
00:09:55,530 --> 00:09:58,150
It's just like, but then I look
 over there and I salute Otto,

So I only want to remove the whitespace in the beginning of  the last line of the example. And not the blank line between the two text blocks.
Thank you for your attention.

Regards from Otto
Op vrijdag 26 juli 2024 om 16:17:13 UTC+2 schreef Ulrich Kapp:

Otto Munters

unread,
Aug 5, 2024, 10:51:19 AM8/5/24
to BBEdit Talk
I found the right Grep to remove a space before a line of words: " (^)([ ]) "
" [ ] " means a space. The square bracket defines a character class, which means it matches any character inside the brackets. In this case, there is only one character, a space, so it matches a space.
Other solutions also removed blank lines, which was not the intention.
Thank you all for your kind help!

Best regards from Otto

Op maandag 29 juli 2024 om 15:00:02 UTC+2 schreef Otto Munters:
Reply all
Reply to author
Forward
0 new messages