in reply to Re^2: Nonrepeating characters in an RE (updated)
in thread Nonrepeating characters in an RE
I find the wording "template" confusing and thought it's about constructing a complicated regex by templates, i.e. like it's done with HTML.
If "template" is supposed to mean character class $chars = "abc.." whose chars are never repeated anywhere in the string, a negated approach is probably the simplest
$str !~ / ([$chars]) .* \1 /x
use v5.12; use warnings; my @words = qw"abc aab abb aba abcd abca"; my $chars = "ad"; for (@words) { say "$_" if $_ !~ / ([$chars]) .* \1 /x }
abc abb # NB: b wasn't in chars abcd
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Nonrepeating characters in an RE (simple)
by hv (Prior) on Aug 16, 2022 at 12:54 UTC | |
by BillKSmith (Monsignor) on Aug 16, 2022 at 13:54 UTC | |
by LanX (Saint) on Aug 16, 2022 at 12:58 UTC |