Help for this page

Select Code to Download


  1. or download this
    #!/usr/bin/perl
    
    ...
    $_ = "#tag1 #tag2 #tag3 #tag1\n";
    1 while s/(#\w{2,})\b.*\K\1\b\h*//;
    print "keeping only the first one:  $_";
    
  2. or download this
                      original:  #tag1 #tag2 #tag3 #tag1
     keeping only the last one:  #tag2 #tag3 #tag1
    keeping only the first one:  #tag1 #tag2 #tag3