itshardtogetone@hotmail.com wrote:
> How do I simplify the regex below so that it matches only the number
> 1, henceforth it should return false if I match $string with $match.
>
> use strict;
> use warnings;
>
> my $string = "10 11 12 13 40";
> my $match = 1;
>
> if ($string =~/^$match | $match | $match$/g){
Do you possibly mean something like:
my $match = qr(\b1\b);
if ( $string =~ /$match/ ) {
which would be true for the string
my $string = "10 11 1 13 40";
but not for your original string.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
Thread Previous
|
Thread Next