Build your own regex out of your user's input.
my @match = qw(; : -); my $match = join('|', map { "\Q$_" } @match); if ('random-text' =~ /$match/) { print "yep\n"; } else { print "nope\n"; }
Note the use of \Q in case your users input regex metacharacters. \Q escapes them so they aren't treated as metacharacters.
"The first rule of Perl club is you do not talk about
Perl club."
-- Chip Salzenberg
In reply to Re: splitting a line by user-defined separators
by davorg
in thread splitting a line by user-defined separators
by a11
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |