On 01/18/2019, at 20:00, Dj <[email protected] 
<mailto:[email protected]>> wrote:
> Hello, my father is hard of hearing and I'd like to send him some closed 
> caption files so he can read the content like you would a book. Is there an 
> easy way to strip data out of the below example so it's only text, and not 
> timestamps and tags?


Hey Dj,

BBEdit already has a command to convert HTML to Text, so part of that's easy.

You can do it from BBEdit > MenuBar > MarkUp > Utilities > Translate HTML to 
Text

Or more conveniently for automating you can do it with AppleScript.

Then let's add in a little find/replace, and Poof!  Job done.

When trying to do this sort of thing often best to have a look around Google 
first.

Google Search:

regex how to remove html tags

The second hit is pretty good:

https://www.regextester.com/93515 <https://www.regextester.com/93515>

I'm not using that, since I'm letting BBEdit do the work for me in this case – 
but I have used that pattern in other cases.

--
Take Care,
Chris

----------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2019/01/18 23:14
# dMod: 2019/01/18 23:14 
# Appl: BBEdit
# Task: Convert HTML to Text and Use RegEx to Remove SubTitle Stamps.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @BBEdit, @Convert, @HTML, @Text, @RegEx, 
@Remove, @SubTitle, @Stamps
----------------------------------------------------------------

tell application "BBEdit"
    tell front text window
        
        translate html to text entity conversion true ¬
            tag removal true ¬
            paragraph conversion true ¬
            create new document true ¬
            without selection only
        
        tell its text
            replace "^(\\d{4}|\\d{2}:\\d{2}:.+)\\R?" using "" options {search 
mode:grep, case sensitive:false, starting at top:true}
        end tell
        
    end tell
end tell

----------------------------------------------------------------

-- 
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 to the group.
Follow @bbedit on Twitter: <https://www.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 post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/bbedit.

Reply via email to