On 03/30/2018, at 23:15, Mariella Scuderi <[email protected] 
<mailto:[email protected]>> wrote:
> sorry of this has been discussed already but I couldn't find anything yet.
> 
> I'd need to add a suffix to duplicates like:
> [FK410002_a]
> [FK410002_b]
> [FK410003_a]
> [FK410003_a]


Hey Mariella,

Do you know how to use a text-filter?

Basic use information is on the BBEdit Extras wiki (link 
<http://bbeditextras.org/wiki/index.php?title=Text_Filters>), and they're 
explained in depth in the user manual.

This Perl text-filter should do the job for you, as long as your text conforms 
to the sample you posted.


#!/usr/bin/env perl -sw
use v5.010; use open qw(:std :utf8); use utf8;

my ($cntr, $tempItem);

$tempItem = "";
$cntr = "a";

while(<>){
   if ( /(\[[a-z]+\d+)(\])/i ) {
      if ( $tempItem eq "$&" ) {
         ++$cntr;
         say "$1_$cntr$2";
      } else {
         $tempItem = $&;
         $cntr = "a";
         print;
      }
   }
}


--
Best Regards,
Chris

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email
"[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://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