Pedro Antonio Reche wrote:
> Hi All;
>
> I would like to match a string  if it has only cero or more of a defined
> set of characters.
> For example:
> if "GACT"  are the characters, then
>
> GACTNGACT ## This string should not be matched because it has the extra
> character N
> GACCCCCCC ## This could be matched;
>
> Any help to solve this problem will be greatly appreciated.
>

Hi Pedro.

This will do what you want.

HTH,

Rob


  use strict;
  use warnings;

  foreach my $string ( qw/GACTNGACT GACCCCCCC/ ) {

    if ( $string !~ /[^GACT]/) {
      printf "String %s passes test\n", $string;
    }
    else {
      printf "String %s fails test\n", $string;
    }
  }

OUTPUT

  String GACTNGACT fails test
  String GACCCCCCC passes test





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to