venkatperl55 has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: dont consider if (......)
by Corion (Patriarch) on Mar 01, 2010 at 07:51 UTC

    Have you looked at perlre? It documents how you can match more than one character in a place when using regular expressions.

      Is this you are expecting?
      Example.
      my $data=<STDIN>; if($data =~ /ipw\.r[^a-p][a-z]*/) { print "Match\n"; } else { print "Not Match\n"; }
      OutPut
      ipw.raasdfdsf Not Match ipw.raasdfdsf Not Match ipw.rgdfgsdfsd Not Match ipw.rrwgorga Match
      A reply falls below the community's threshold of quality. You may see it by logging in.
Re: dont consider if (......)
by Anonymous Monk on Mar 01, 2010 at 08:39 UTC

    The following simple regular expression solves your homework-assignment.

    if ($name =~ s/^r.wpi//i) { print ("$name fits\n"); } else { print ("$name does not fit\n"); }

    But it requires the following code before to make it work:

    my $name = "ipw.raxwgorga"; if ((substr($name, 0,5) eq "ipw.r") && ( (sort (split(undef, substr($n +ame, 5, length($name) - 5))))[0] eq substr($name, 5,1))) { $name = "r.wpi".$name; };

    Btw.: I agree to you that thinking on your own is an overrated concept; however I recommend you to use this service next time.