As far as I know, there is no one-pass solution to this problem. (I'd love to 
know if there is.) But there' a simple quick-and-dirty multi-pass solution. 
Here's one way to do it.

First, add a some character that doesn't occur anywhere else in the file to the 
beginning of each month line. I'm using a bullet here:

        Find: ^\s*[a-z]+ \d{4}$
        Replace: •&
        Replace all

Gives us

•        April 2020
            (Individual talks will be added before the end of the month for a 
while.)
                [play audio] 25 Being Responsible
                [play audio] 24 In the Land of Wrong View
                [play audio] 05 Owners of Our Actions
                [play audio] 04 Wealth & Strength
                [play audio] 03 A Skillful Heart
                [play audio] 02 Stop & Think
                [play audio] 01 A Mirror for the Mind
•        March 2020
            Full month zip
                [play audio] 31 Worry
                [play audio] 30 Put the Other Person’s Heart in Yours
                ...

Next, write a pattern to replace the first (if any) [play audio] line in each 
month:

        Find: (?s)(^•\s*([a-z]+) (\d{4})\n[^•]*?)(\[play audio\] (\d\d))
        Replace: \1\3-\2-\5
        Replace all

Gives us:

•        April 2020
            (Individual talks will be added before the end of the month for a 
while.)
                2020-April-25 Being Responsible
                [play audio] 24 In the Land of Wrong View
                [play audio] 05 Owners of Our Actions
                [play audio] 04 Wealth & Strength
                [play audio] 03 A Skillful Heart
                [play audio] 02 Stop & Think
                [play audio] 01 A Mirror for the Mind
•        March 2020
            Full month zip
                2020-March-31 Worry
                [play audio] 30 Put the Other Person’s Heart in Yours
                [play audio] 29 Protection Through Mindfulness
               ...

Now just keep hitting Cmd-Shift-= repeatedly, replacing the first unprocessed 
line of each month each time, until it fails. (If you have no more than a 
hundred [play audio] lines per month, this will take no more than a couple of 
minutes — i.e., much less time than it would take to find a smarter solution. 
If you have a thousand lines in a month, you will need some other solution.

Finally, one last search-and-replace will delete all the bullet that you 
inserted in step one.

Regards,

        Neil Faiman

> On Apr 30, 2020, at 3:10 PM, Peter Kaufman <pkauf...@gmail.com> wrote:
> 
> Folks,
> 
> I love BBEdit (v13.0.6) and hope this can do the trick!  I would rather not 
> have to resort to sed/awk/cut/paste.
> 
> INPUT:
>         April 2020
>             (Individual talks will be added before the end of the month for a 
> while.)
>                 [play audio] 25 Being Responsible
>                 [play audio] 24 In the Land of Wrong View
>                 [play audio] 05 Owners of Our Actions
>                 [play audio] 04 Wealth & Strength
>                 [play audio] 03 A Skillful Heart
>                 [play audio] 02 Stop & Think
>                 [play audio] 01 A Mirror for the Mind
>         March 2020
>             Full month zip
>                 [play audio] 31 Worry
>                 [play audio] 30 Put the Other Person’s Heart in Yours
>                 [play audio] 29 Protection Through Mindfulness
>                 [play audio] 28 Inner Worlds
>                 [play audio] 27 Four Mountains Moving In
>                 [play audio] 26 Interdependence
>                 [play audio] 25 Endurance & Contentment
>                 [play audio] 24 Alone Together
>                 [play audio] 23 Remembering Luang Lung
>                 [play audio] 12 Virtues and Values (Brazil)
>         February 2020
>             Full month zip
>                 [play audio] 16 Between Right & Wrong
>                 [play audio] 14 Know the Dhamma by Its Results
>                 [play audio] 13 The Third and a Half Noble Truth
>  
> OUTPUT:
> Each [play audio] \d\d would be replaced with the previous YYYY-MONTH-\d\d
> e.g. 
> 2020-April-25 Being Responsible
> :               :               :
> 2020-April-01 A Mirror for the Mind
>                 2020-March-31 Worry
>                                 :               :               :
>  
>  
> I know how to start this incantation:
> \W*(January|February|March|April|May|June|July|August|September|October|November|December)
>  (\d\d\d\d)\n.*$(\W*\[play audio\] (\d\d) (.*$)){1,}
>  
> But not how to do this.  Are there variables one can assign within BBEdit? I 
> hate to leave BBEdit in order to apply sed/awk/grep.
>  
> Thanks in advance!!!
>  
> Peter
> 
> 
> 
> -- 
> This is the BBEdit Talk public discussion group. If you have a feature 
> request or need technical support, please email "supp...@barebones.com" 
> rather than posting here. Follow @bbedit on Twitter: 
> <https://twitter.com/bbedit <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 bbedit+unsubscr...@googlegroups.com 
> <mailto:bbedit+unsubscr...@googlegroups.com>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/bbedit/3081da21-3919-49a8-a16a-d634eefa3f17%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/bbedit/3081da21-3919-49a8-a16a-d634eefa3f17%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 "supp...@barebones.com" 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 bbedit+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/9C0637BC-189B-4726-BB00-BF01BA335612%40faiman.org.

Reply via email to