develooper Front page | perl.beginners | Postings from May 2008

howto simplfy this regex if ($string =~/^$match | $match | $match$/g){

Thread Next
From:
itshardtogetone
Date:
May 3, 2008 22:20
Subject:
howto simplfy this regex if ($string =~/^$match | $match | $match$/g){
Hi,
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){
    print "match";
}else{
   print "unmatch";
};


Thread Next


Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About