Hi Christopher,

You could use a perl Text Filter.

Place this script in *~/Library/Application Support/BBEdit/Text 
Filters/add_reference_numbers.pl*:

*#!/usr/bin/env perl*

*use v5.14;*

*use strict;*

*use warnings;*


*$/ = undef;*


*my $i = 1;*

*print <> =~ s/(?<=BEGINREF\s)\d*(?=ENDREF)/$i++/grimse;*


*=for test*


*BEGINREF ENDREF*


*foo*


*BEGINREF ENDREF buzz*


*bar*

*    BEGINREF ENDREF.*


*baz*



*hello   BEGINREF ENDREF world*


*BEGINREF*

*ENDREF*


*=cut*

And call it from menu *Text > Apply Text Filter > add_reference_numbers.*

HTH,

Jean Jourdain


On Monday, August 21, 2023 at 10:32:09 PM UTC+2 Christopher Werby wrote:

> I'm trying to bring Word documents with footnote reference markers into 
> BBEdit in plain text for further editing.  I can surround the special 
> footnote reference markers in Word with strings. I used to have a macro in 
> Word which could grab that reference marker and turn it into text so that 
> it would paste into BBEdit.  But that macro has broken.
>
> Now, in BBEdit, I just have the markers without the actual reference 
> number:
>
> BEGINREF ENDREF
>
> What I would like to do is search using a non-capturing look ahead 
> assertion for the ENDREF (?=ENDREF) and prefix it with the number of 
> matches.  It would look like:
>
> BEGINREF 1ENDREF
>
> BEGINREF 2ENDREF
>
> BEGINREF 3ENDREF ...
>
> Is there a way of doing that?  In UNIX there's a count option flag, but I 
> can't think of how to use that here.
>

-- 
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/4ef04c25-6c1c-44f8-b07d-0b8a9639e3a4n%40googlegroups.com.

Reply via email to