I do this with a text factory.
First step.
Grep: ^(\d{2}:\d{2}:\d{2},\d{3}) -->
(\d{2}:\d{2}:\d{2},\d{3})\n([^\n]*[^.\n])\n([^\n]+(?:\n[^\n]+)*)\n+(\d+)\n(\d{2}:\d{2}:\d{2},\d{3})
--> (\d{2}:\d{2}:\d{2},\d{3})\n((?-i)[^A-Z][^\n]{0,15})\n
Replace: \1 --> \6\n\3\n\n\4\n\5 --> \6\n\7\n
Description:Replace the second part of the top timestamp with the second
part of the bottom timestamp, but only if below the second timestamp there
is a solitary word without a capital letter, or a sentence containing a
maximum of 15 characters
Second step:
Grep: ^([^\n]+)(?<!\.)\n[^\n]*\n[^\n]*\n[^\n]*\n((?-i)[^A-Z][^\n]{0,15})\n\n
Replace: \1 \2\n\n
Description:Move single word without capital letter incl. punctuation mark
to the end of the 4th line up, if this line does not end with a full stop.
Does the same with multiple words that are up to 15 characters together.
Works fine with subtitles in srt format.
Op dinsdag 8 april 2025 om 10:56:30 UTC+2 schreef Otto Munters:
> Thanks a lot for all help. This problem is solved, I've found the working
> pattern!
> Otto
> Op dinsdag 8 april 2025 om 04:35:50 UTC+2 schreef GP:
>
>> In order to work with all possible subtitle sequence numbers you'll need
>> to use \d+ instead of \d\d in your grep patterns so your two search
>> patterns should be:
>>
>> (^\d+\n\d.+\n.+)\n\n\d+\n\d.+\n([a-z]+[\W]*)\n
>>
>> and
>>
>> (^\d+\n\d.+ )(.+)\n(.+)\n\n\d+\n\d.+ (.+)\n([a-z]+[\W]*)\n
>>
>> On Monday, April 7, 2025 at 4:12:23 PM UTC-7 Roland Küffner wrote:
>>
>>> A similar but slightly shorter version:
>>>
>>> search:
>>> (^\d\d\n\d.+\n.+)\n\n\d\d\n\d.+\n([a-z]+[\W]*)\n
>>>
>>> replace:
>>> \1 \2\n
>>>
>>> - turn "Case sensitive" on
>>> - currently works only if the subtitle text is always on one line
>>> - currently does not account for differing amounts of empty lines
>>> between the text blocks
>>> - the new end of the time stamp is deleted - if you can live with that …
>>>
>>> … if not, you could extend the pattern to replace that too
>>> search
>>> (^\d\d\n\d.+ )(.+)\n(.+)\n\n\d\d\n\d.+ (.+)\n([a-z]+[\W]*)\n
>>>
>>> replace
>>> \1\4\n\3 \5\n
>>>
>>> Regards, Roland
>>>
>>> On Sun, Apr 6, 2025 at 4:41 PM Otto Munters <[email protected]> wrote:
>>>
>>>> Example of a subtitle from which I want to move the single word in the
>>>> second timestamp to the end of the subtitle in the first timestamp.
>>>> Is it possible to do that with a regex in BBedit? With Python or
>>>> Applescript, I can't work.
>>>>
>>>> 50
>>>> 00:04:35,000 --> 00:04:42,840
>>>> However, what can happen is this can come at the cost of disregarding
>>>> the larger
>>>>
>>>> 51
>>>> 00:04:42,840 --> 00:04:43,000
>>>> whole.
>>>>
>>>>
>>>> Thank you for helping me!
>>>> Otto
>>>>
>>>> --
>>>>
>>> This is the BBEdit Talk public discussion group. If you have a feature
>>>> request or believe that the application isn't working correctly, please
>>>> email "[email protected]" rather than posting here. Follow @bbedit
>>>> on Mastodon: <https://mastodon.social/@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 visit
>>>> https://groups.google.com/d/msgid/bbedit/2a6c9959-19e8-4aad-bad3-4b0c7973aa5an%40googlegroups.com
>>>>
>>>> <https://groups.google.com/d/msgid/bbedit/2a6c9959-19e8-4aad-bad3-4b0c7973aa5an%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>>
--
This is the BBEdit Talk public discussion group. If you have a feature request
or believe that the application isn't working correctly, please email
"[email protected]" rather than posting here. Follow @bbedit on Mastodon:
<https://mastodon.social/@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 visit
https://groups.google.com/d/msgid/bbedit/be63113d-a3a8-4d6f-9482-ea83bbfa5285n%40googlegroups.com.