search pattern

142 views
Skip to first unread message

Otto Munters

unread,
Dec 27, 2024, 4:47:39 AM12/27/24
to BBEdit Talk
Hello BB friends

In a subtitle project I want to remove segments containing only a time stamp, without subtitle.
Example:
3
00:00:06,000 --> 00:00:08,000
We'll finish the next.

4
00:00:08,000 --> 00:00:11,000

5
00:00:56,000 --> 00:01:02,000
We saw yesterday that this 
knowledge is growing clarity

should become:
3
00:00:06,000 --> 00:00:08,000
We'll finish the next.

5
00:00:56,000 --> 00:01:02,000
We saw yesterday that this 
knowledge is growing clarity

So the number above and the timestamp without text underneath should be removed, leaving only one empty line in between the two remaining segments.

Anybody can help me? Much appreciated!
Otto
Message has been deleted

Alberto Gutiérrez

unread,
Dec 27, 2024, 5:16:02 AM12/27/24
to BBEdit Talk
Hi, Otto. I think this would work:

(?<=\r)\d+\r\d(.+?)(?=\r\r)

Looks for a return, then a digit one or more times, a return,  a digit (the first of the line with the time stamp), and anything up to two returns.

Message has been deleted

jj

unread,
Dec 27, 2024, 10:24:44 AM12/27/24
to BBEdit Talk
Hi Otto,

Here is a commented regular expression that should match what you want to remove.
Copy and paste it as is in the Find window using the menu 'Edit > Paste > and Select', otherwise it will be escaped.

(?xx)                                               # Allow comments and ignore whitespace.
(?(DEFINE)                                          # Define reusable patterns.
    (?<TIMESTAMP>                                   # TIMESTAMP named pattern.
        \d{2,}:[0-5][0-9]:[0-5][0-9],\d{3}
    )
)
^                                                   # Start of line.
\d+                                                 # One or more digits.
\h*                                                 # Zero or more horizontal whitespace.
\v                                                  # A vertical whitespace.
(?&TIMESTAMP)\h*-->\h*(?&TIMESTAMP)                 # Two TIMESTAMP patterns separated by an arrow.
(
    \v\h*\v                                         # Followed by a blank line
|                                                   # or
    \Z                                              # the End Of File.
)

Leave the Replace field empty.

For definitive PCRE2 pattern documentation, see https://www.pcre.org/current/doc/html/pcre2pattern.html.

HTH

Jean Jourdain

Otto Munters

unread,
Dec 28, 2024, 2:04:55 AM12/28/24
to BBEdit Talk
Thank you all for helping me. I found the grep I was looking for!
Otto

Op vrijdag 27 december 2024 om 20:54:44 UTC+5:30 schreef jj:

Otto Munters

unread,
Dec 28, 2024, 2:09:38 AM12/28/24
to bbe...@googlegroups.com
Hello Ulrich
Thanks to your help I found the grep I was looking for! Thanks a lot.
Wish you all the best,
Best regards, Otto


Op 27 dec 2024, om 15:46 heeft 'Ulrich Kapp' via BBEdit Talk <bbe...@googlegroups.com> het volgende geschreven:

Hi Otto,
try this search pattern

^\d{1,}\r\d{2}:\d{2}:\d{2},\d{3} --> \d{2}:\d{2}:\d{2},\d{3}\r\r

and just delete (replace with empty string).
This will do for your example and hopefully for every entry without any text.

Happy new year and best wishes!
Ulrich
--
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 "sup...@barebones.com" rather than posting here. Follow @bbedit on Mastodon: <https://mastodon.social/@bbedit>
---
You received this message because you are subscribed to a topic in the Google Groups "BBEdit Talk" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/bbedit/FWpRHb_mkl0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to bbedit+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/bbedit/bb281950-7828-4e0e-aea9-6ba924060267n%40googlegroups.com.

john Mitchell

unread,
Dec 29, 2024, 8:50:30 PM12/29/24
to bbe...@googlegroups.com
Hi all

bbedit version 15.1.3 (15B62, Apple Silicon)
macOS 15.2 (24C101)

I get this completion example (inPython):

change_individual_name(<# level_families #>, <# family_id #>, <# child_id #>, <# new_name #>)

is there a (smart) way to accept the variable names instead of deleting the delimiters. 
In this example the first 3 arguments are identical, but the last argument will have a custom edit, and of course there will be great variation in arguments



John Mitchell

Roland Küffner

unread,
Jan 16, 2025, 5:43:35 PM1/16/25
to bbe...@googlegroups.com
Hi,
you could replace the default "Go to Next Placeholder" functionality (= pressing TAB) by a custom script that removes the Placeholder syntax "<#...#>" and jumps to the next Placeholder.

I tried to record a quick and dirty Applescript that worked on my (very basic) tests:
tell application "BBEdit"
activate
replace "<#(.+?)#>" using "\\1" searching in selection of text window 1 options {search mode:grep}
end tell
tell application "System Events" to keystroke " "

Please mind that the keystroke command in the last line has a literal tab in it's string – you could also use keystroke (ASCII character 9)

The placeholder must already be selected (probably by having pressed TAB).

All you would have to to is to save such a script, give it a keyboard shortcut, jump to the first placeholder (TAB) and use your shortcut from there,
Not ideal, but maybe better than removing them brackets with bare hands.
Regards
Roland


--
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 "sup...@barebones.com" 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 bbedit+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/bbedit/9838765A-E34D-4068-8A9C-C379FF74FA08%40cqr.net.au.

john Mitchell

unread,
Jan 16, 2025, 8:47:03 PM1/16/25
to bbe...@googlegroups.com
tks Roland - will experiment!


regards

John


U1005/2 Dind Street, Milsons Point, NSW 2061 Australia 
Email:  john.m...@cqr.net.au • Mob: +61 410 318 131
Skype: jrmitchell     

  

  

Reply all
Reply to author
Forward
0 new messages