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

Re: [PBML] pattern matching

Expand Messages
  • Pavlos Parissis
    Hello all, I think I found an nice solution. so let me remind you the story a file with the following /mnt Myrule /koko/ 2rule dd/dd ff /etc/passwd tete
    Message 1 of 25 , Jan 2, 2004
    • 0 Attachment
      Hello all,

      I think I found an nice solution.
      so let me remind you the story
      a file with the following
      /mnt Myrule
      /koko/ 2rule
      dd/dd ff
      /etc/passwd tete
      /goo/goo r+t
      !/var/log/messages.*
      /mnt/extra/system_backup/etc t+t+t
      !/mnt/extra/system_backup/etc/reoback
      =/tmp g+gg
      =/foo r+r
      =ho/ddd t+t
      =/bar My
      =/slice my

      it looks like the side.conf file
      and I want to grab only the line that start with full path of "dir or files" and
      word+word or a word only with the capital first letter.
      Valid lines are all the lines that start with ! or = or /
      and for each of the abover correct lines the path must be the full path. The
      problem
      here is that I can not find a regex to math only valid filesystem paths.
      Now if the the path is like this /foo\ff it will be matched:(
      Any ideas about this?
      The code is this

      18 open(CONF,"<$conf");
      19 while (defined($line = <CONF>)) {
      20 my $path;
      21 my $flags;
      22 chomp($line);
      23 next if ($line =~ /^#.*/); # no comments.
      24 next if ($line =~ /^\s+/); # no leading white.
      25 next if ($line =~ /^\s+$/); # no trailing white.
      26 next unless length $line; # null and empty lines.
      27 ($path,$flags) = split /\s+/, $line;
      28 if ( !( $path =~ m/^(!|\/|=)/) ){
      29 print "wrong format $path\n";
      30 next;
      31 }
      32 if ( defined($flags) and $flags =~ /\S/ ) { # accept only flags with
      this w+w+w or this First.
      33 next if ( (!($flags =~ /^(\w\+)+\w$/)) and (!($flags =~
      /^[A-Z]\w+/)) );
      34 }
      35 if ($path =~ m/^(!)(\/.*)/) {
      36 push @excluded_dirs, $2;
      37 next;
      38 } elsif ($path =~ m/^(=)(\/.*)$/) {
      39 $dirs_only{"$2"} = "$flags";
      40 next;
      41 } elsif ( $path =~ m/^(\/.*)$/ ) {
      42 $dirs_check{"$1"} = "$flags";
      43 next;
      44 } else { print "unmatched $path\n";}
      45
      46 }
      47 close CONF;

      and gives me
      wrong format dd/dd
      unmatched =ho/ddd
      #####exlcuded
      /var/log/messages.*
      /mnt/extra/system_backup/etc/reoback
      #####match only
      /bar My
      /foo r+r
      #####search only
      /mnt/extra/system_backup/etc t+t+t
      /mnt Myrule
      /goo/goo r+t

      Pavlos


      --
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      I love having the feeling of being in control
      while i have the sensation of speed

      The surfer of life
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      GnuPG Key: FB1E6AE7
      Fingerprint A9AE EA0C EE1F FBD0 5B6F 3F77 2782 EFE2 FB1E 6AE7
      Get my key here: http://users.hol.gr/~p_pavlos/pubpgpkey.txt
    • satish
      Dear Sir, Can anyone suggest me how to write pattern matching for ph*.jpg, displaying all the jpg files starting from ph. Thanks and regards, Satish KM
      Message 2 of 25 , Dec 7, 2005
      • 0 Attachment
        Dear Sir,

        Can anyone suggest me how to write pattern matching
        for ph*.jpg, displaying all the jpg files starting
        from ph.

        Thanks and regards,
        Satish KM



        __________________________________________________
        Do You Yahoo!?
        Tired of spam? Yahoo! Mail has the best spam protection around
        http://mail.yahoo.com
      • Prakash Kumar
        /^ph.* .jpg$/i -Prak
        Message 3 of 25 , Dec 7, 2005
        • 0 Attachment
          /^ph.*\.jpg$/i

          -Prak


          On Wed, 7 Dec 2005, satish wrote:

          >
          >
          >
          > Dear Sir,
          >
          > Can anyone suggest me how to write pattern matching
          > for ph*.jpg, displaying all the jpg files starting
          > from ph.
          >
          > Thanks and regards,
          > Satish KM
          >
          >
          >
          > __________________________________________________
          > Do You Yahoo!?
          > Tired of spam? Yahoo! Mail has the best spam protection around
          > http://mail.yahoo.com
          >
          >
          >
          > Unsubscribing info is here: http://help.yahoo.com/help/us/groups/groups-32.html
          > Yahoo! Groups Links
          >
          >
          >
          >
          >
          >
          >
        • srinivas reddy
          I think this would work: /^ph.* .jpg$/ Thanks, Srinivas. ... -- Best Regards, Srinivas Reddy...... [Non-text portions of this message have been removed]
          Message 4 of 25 , Dec 7, 2005
          • 0 Attachment
            I think this would work:

            /^ph.*\.jpg$/


            Thanks,
            Srinivas.

            On 12/8/05, satish <satyakm79@...> wrote:
            >
            >
            >
            >
            > Dear Sir,
            >
            > Can anyone suggest me how to write pattern matching
            > for ph*.jpg, displaying all the jpg files starting
            > from ph.
            >
            > Thanks and regards,
            > Satish KM
            >
            >
            >
            > __________________________________________________
            > Do You Yahoo!?
            > Tired of spam? Yahoo! Mail has the best spam protection around
            > http://mail.yahoo.com
            >
            >
            >
            > Unsubscribing info is here:
            > http://help.yahoo.com/help/us/groups/groups-32.html
            > Yahoo! Groups Links
            >
            >
            >
            >
            >
            >
            >
            >


            --
            Best Regards,
            Srinivas Reddy......


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