To solve the presented problem this type of approach is the one I would use too but with List::Util::uniq for speed and clarity. Core modules with XS are ideal for this type of task.
#!/usr/bin/env perl use strict; use warnings; use List::Util 'uniq'; my $tags = '#tag1 #tag2 #tag3 #tag1'; my $uniq = join ' ', uniq split / /, $tags; print "Orig: $tags\nUniq: $uniq\n";
🦛
In reply to Re^2: Regex: remove non-adjacent duplicate hashtags
by hippo
in thread Regex: remove non-adjacent duplicate hashtags
by element22
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |