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

RE: [PBML] Reg Exp and pattern matching

Expand Messages
  • Nathan.Jeffrey@dhs.vic.gov.au
    They match the beginning and end of the string, respectively. N John Drabinowicz 01/11/2002 12:47 AM Please respond to perl-beginner To:
    Message 1 of 8 , Oct 31, 2002
      They match the beginning and end of the string, respectively.

      N





      John Drabinowicz <jdrab@...>
      01/11/2002 12:47 AM
      Please respond to perl-beginner


      To: "'perl-beginner@yahoogroups.com'" <perl-beginner@yahoogroups.com>
      cc:
      Subject: RE: [PBML] Reg Exp and pattern matching


      Hi Ravi and all,

      in Ravi's if ($line =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/)
      what do the ^ and the $ at the end signify?

      Thanks for all the help, I ended up using this:
      if ($line =~ /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/)

      it works great, that was the last peice I needed to fic my little code
      snippit below:
      -cut---------------------------------------------------
      $host =~ tr/A-Z/a-z/; # make all lower case
      if ($host eq "localhost"){
      # convert to unqualified host name (in lower case)

      }
      elsif ($host =~ m/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/){
      # convert to unqualified host name (in lower case)

      }
      -cut---------------------------------------------------


      -----Original Message-----
      From: Ravi Kiran [mailto:RKiran@...]
      Sent: Wednesday, October 30, 2002 7:17 PM
      To: 'perl-beginner@yahoogroups.com'
      Subject: RE: [PBML] Reg Exp and pattern matching


      U can also use
      if ($line =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) if ($line =~
      /^(\d{1,3}\.){3}\d{1,3}$/)
      -RK

      -----Original Message-----
      From: John Drabinowicz [mailto:jdrab@...]
      Sent: Wednesday, October 30, 2002 8:44 AM
      To: perl-beginner@yahoogroups.com
      Subject: [PBML] Reg Exp and pattern matching


      Hi Gang,

      I'm still not very deep into regular expressions, but I need to see if a
      variable is a name of an IP address.
      The problem that I'm having is that the numbers between the dots can be
      from
      1-3 digits, can anyone
      out there help me? what I've got so far is:

      use strict;
      use Sys::Hostname;
      use Socket;
      my $abc = "1.2.3.4";
      if ($abc =~ m/[0-9]\.[0-9]\.[0-9]\.[0-9]/)
      {
      print "found it\n";
      }
      else
      {
      print "didn't find it\n";
      }

      Thanks,

      John D.


      [Non-text portions of this message have been removed]



      Yahoo! Groups Sponsor

      ADVERTISEMENT

      <http://rd.yahoo.com/M=237459.2482214.3917349.2146399/D=egroupweb/S=17050069
      51:HM/A=1267611/R=0/*http://ad.doubleclick.net/jump/N2524.Yahoo/B1071650;sz=
      300x250;ord=1035996335939911?>

      <http://us.adserver.yahoo.com/l?M=237459.2482214.3917349.2146399/D=egroupmai
      l/S=:HM/A=1267611/rand=262611687>

      Unsubscribing info is here:
      http://help.yahoo.com/help/us/groups/groups-32.html
      <http://help.yahoo.com/help/us/groups/groups-32.html>

      Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service
      <http://docs.yahoo.com/info/terms/> .




      [Non-text portions of this message have been removed]



      Unsubscribing info is here:
      http://help.yahoo.com/help/us/groups/groups-32.html

      Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/



      [Non-text portions of this message have been removed]



      Unsubscribing info is here:
      http://help.yahoo.com/help/us/groups/groups-32.html

      Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/







      _________________________________________________________________________________

      This email contains confidential information intended only for the person named above and may be subject to legal privilege. If you are not the intended recipient, any disclosure, copying or use of this information is prohibited. The Department provides no guarantee that this communication is free of virus or that it has not been intercepted or interfered with. If you have received this email in error or have any other concerns regarding its transmission, please notify Postmaster@...
      _________________________________________________________________________________
    Your message has been successfully submitted and would be delivered to recipients shortly.