in reply to Re: Regex: remove non-adjacent duplicate hashtags
in thread Regex: remove non-adjacent duplicate hashtags
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";
🦛
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Regex: remove non-adjacent duplicate hashtags
by perlfan (Parson) on Jul 26, 2022 at 06:27 UTC | |
by AnomalousMonk (Archbishop) on Jul 26, 2022 at 10:19 UTC |