Loading ...
Sorry, an error occurred while loading the content.

Need help with reg expression

Expand Messages
  • asp66
    Hi all, I have a quick question. I am trying to make sure only 8.3 type string is matched but the below code prints 8.4 . Is there a way I could make sure it
    Message 1 of 4 , Oct 1, 2010
    • 0 Attachment
      Hi all,

      I have a quick question. I am trying to make sure only 8.3 type string is matched but the below code prints 8.4 . Is there a way I could make sure it gets ignored or return false since its not matching 8.3

      $string = "abcdefgh.txtt" ;
      if($string =~ m/^\S{1,8}\.\S{0,3}/){print $string} ;

      any help appreciated,
      regards
    • merlyn@stonehenge.com
      ... asp66 Hi all, asp66 I have a quick question. I am trying to make sure only 8.3 type string is matched but the below code prints 8.4 . Is there a way I
      Message 2 of 4 , Oct 1, 2010
      • 0 Attachment
        >>>>> "asp66" == asp66 <asp66@...> writes:

        asp66> Hi all,
        asp66> I have a quick question. I am trying to make sure only 8.3 type string is matched but the below code prints 8.4 . Is there a way I could make sure it gets ignored or return false since its not matching 8.3

        asp66> $string = "abcdefgh.txtt" ;
        asp66> if($string =~ m/^\S{1,8}\.\S{0,3}/){print $string} ;

        You're missing the ending anchor ($) even though you have the beginning
        anchor (^).

        --
        Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
        <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
        Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
        See http://methodsandmessages.posterous.com/ for Smalltalk discussion
      • Bilashi Sahu
        Try with this, it works for me my $str1 = abcdefgh.txtt ; if ($str1 =~ /^ w{8} . w{3}$/) { print $str1 n ; } else { print not 8.3 string n ; } From:
        Message 3 of 4 , Oct 1, 2010
        • 0 Attachment
          Try with this, it works for me

          my $str1 = "abcdefgh.txtt";
          if ($str1 =~ /^\w{8}\.\w{3}$/)
          {
          print "$str1\n";
          }
          else
          {
          print "not 8.3 string\n";
          }





          From: perl-beginner@yahoogroups.com
          To: perl-beginner@yahoogroups.com
          Cc:
          Sent: Friday, October 1, 2010 12:05:54 PM
          Subject: [PBML] Need help with reg expression



          Hi all,

          I have a quick question. I am trying to make sure only 8.3 type string is matched but the below code prints 8.4 . Is there a way I could make sure it gets ignored or return false since its not matching 8.3

          $string = "abcdefgh.txtt" ;
          if($string =~ m/^\S{1,8}\.\S{0,3}/){print $string} ;

          any help appreciated,
          regards







          [Non-text portions of this message have been removed]
        • 秦斌
          try if($string =~ m/^ S{1,8} . S{0,3}$/){print $string} ; 2010/10/2 asp66 ... [Non-text portions of this message have been removed]
          Message 4 of 4 , Oct 4, 2010
          • 0 Attachment
            try
            if($string =~ m/^\S{1,8}\.\S{0,3}$/){print $string} ;


            2010/10/2 asp66 <asp66@...>

            >
            >
            > Hi all,
            >
            > I have a quick question. I am trying to make sure only 8.3 type string is
            > matched but the below code prints 8.4 . Is there a way I could make sure it
            > gets ignored or return false since its not matching 8.3
            >
            > $string = "abcdefgh.txtt" ;
            > if($string =~ m/^\S{1,8}\.\S{0,3}/){print $string} ;
            >
            > any help appreciated,
            > regards
            >
            >
            >


            [Non-text portions of this message have been removed]
          Your message has been successfully submitted and would be delivered to recipients shortly.