> On May 30, 2023, at 8:23 AM, Otto Munters <[email protected]> wrote:
> 
> Hello, I am a new BBEdit user and want to remove all timings from a srt file 
> to use it as a text document. It looks like this now:
> 1
> 00:00:33,360 --> 00:00:45,060
> Welcome. Lovely to see you all. We
> should take our time to introduce
> 
> 2
> 00:00:46,560 --> 00:00:52,380
> the rules. Just like you have ashram
> rules, we have rules for self inquiry.  
> 
> 3
> 00:00:55,200 --> 00:01:01,080
> Vedanta is an ancient tradition,
> science of self inquiry
> 
> All the first two lines of each paragraph (page number and timing) I want to 
> remove. I also want to remove the blank lines so that one large block of text 
> remains.

I don’t know the exact rules, so I’m making a guess. The following pattern will 
remove all occurrences of

an (optional) empty line (no text at all), followed by
a line containing one or more digits at the beginning, and nothing else, 
followed by
a line
starting with a string of digits, decimal points, commas, and colons
followed by the string “ —> ”
followed by another string of digits, decimal points, commas, and colons
and nothing else.

Here’s the recipe. With the document you want to clean up open in a BBEdit 
window, open the find-and-replace dialog (Search menu -> Find…, or Command-F).

Paste the following string in the “Find:” field:

(?s)^\n?\d+\n[0-9.,:]+ --> [0-9.,:]+\n

Make sure the “Replace:” field is empty.

Check the “Grep” and “Wrap around” boxes. Clear the “Case sensitive”, “Entire 
word”, and “Selected text only” boxes.

Click “Replace All”.

When I do this with your example text in the document window, I end up with

Welcome. Lovely to see you all. We
should take our time to introduce
the rules. Just like you have ashram
rules, we have rules for self inquiry.  
Vedanta is an ancient tradition,
science of self inquiry

Detailed explanation of the Grep search string:

(?s) says that this search treats the entire document as the string to be 
processed, rather than processing each line independently.
^ says to start searching at the start of a line.
\n? matches a new-line character if there is one. (i.e., in conjunction with 
the preceding ^, it matches an empty line.)
\d+ matches a string of one or more digits.
\n matches a new-line character. (In conjunction with the preceding \d+, it 
matches a line containing only a string of digits.)
[0-9.,:]+ matches a string of one or more digits, decimal points, commas, 
and/or colons.
 --> matches that specific string of characters. (You can’t see them here, but 
the spaces are part of the string — that is, it is the five characters space, 
hyphen, hyphen, greater-than, space.)
[0-9.,:]+ matches a second string of one or more digits, decimal points, 
commas, and/or colons.
\n matches a new-line character. (In conjunction with the preceding three 
elements, it matches a time-stamp line.)

Then the effect of the “Replace all” is to replace each such two-or-three line 
string with “nothing,” i.e., to delete it.

Cheers,
Neil Faiman

> On May 30, 2023, at 8:23 AM, Otto Munters <[email protected]> wrote:
> 
> Hello, I am a new BBEdit user and want to remove all timings from a srt file 
> to use it as a text document. It looks like this now:
> 1
> 00:00:33,360 --> 00:00:45,060
> Welcome. Lovely to see you all. We
> should take our time to introduce
> 
> 2
> 00:00:46,560 --> 00:00:52,380
> the rules. Just like you have ashram
> rules, we have rules for self inquiry.  
> 
> 3
> 00:00:55,200 --> 00:01:01,080
> Vedanta is an ancient tradition,
> science of self inquiry
> 
> All the first two lines of each paragraph (page number and timing) I want to 
> remove. I also want to remove the blank lines so that one large block of text 
> remains.
> 
> Can anyone help me with the code I can use as a Grep?
> Thanks in advance!
> 
> -- 
> This is the BBEdit Talk public discussion group. If you have a feature 
> request or need technical support, please email "[email protected]" 
> 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 [email protected] 
> <mailto:[email protected]>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/bbedit/8b13b1cd-1b61-475b-90cf-7530b3aeb928n%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/bbedit/8b13b1cd-1b61-475b-90cf-7530b3aeb928n%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "[email protected]" 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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/EC692F51-CD9F-495D-B827-67A5CA6A6273%40faiman.org.

Reply via email to