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

FIXED Re: PS Re: [PBML] REGEX - Please de-confuse me please

Expand Messages
  • Gordon Stewart
    FIXED if ($subj !~ m/$subject/i){ print TEST 2 - $subj NOT included in $subject n ; while ($subject =~ m/^ /i){ $subject =~ s/^ //i; } print Subject 1A:
    Message 1 of 6 , Jul 1, 2003
    • 0 Attachment
      FIXED

      if ($subj !~ m/$subject/i){
      print "TEST 2 - $subj NOT included in $subject\n";


      while ($subject =~ m/^ /i){ $subject =~ s/^ //i; }
      print "Subject 1A: '$subject' - '$subj'\n\n";
      $subject = "$subj $subject";
      print "Subject 1B: '$subject' - '$subj'\n\n";


      }



      LOL - over 1600 people on this group & no one is awake when I am (i'm off
      to bed..)

      G


      [Non-text portions of this message have been removed]
    • Jeff 'japhy' Pinyan
      ... This checks to see if $subject (as a regex) can be found case-insensitively in $subj. Is this what you are trying to do? Please be more clear. ... That
      Message 2 of 6 , Jul 1, 2003
      • 0 Attachment
        On Jul 2, Gordon Stewart said:

        >if ($subj !~ m/$subject/i){

        This checks to see if $subject (as a regex) can be found
        case-insensitively in $subj. Is this what you are trying to do? Please
        be more clear.

        > while ($subject =~ m/^ /i){ $subject =~ s/^ //i; }

        That /i modifier is a complete waste here, and this line should be
        rewritten as

        s/^ +//;

        or perhaps

        s/^\s+//;

        if you want to remove all forms of leading whitespace.

        --
        Jeff "japhy" Pinyan japhy@... http://www.pobox.com/~japhy/
        RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/
        <stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.
        [ I'm looking for programming work. If you like my work, let me know. ]
      • Jeff 'japhy' Pinyan
        ... This sounds like the job for a hash, not a string with regexes on it! for $new_subj (@list_of_subjects) { $subjects{$new_subj} = 1; } or even @subjects{
        Message 3 of 6 , Jul 1, 2003
        • 0 Attachment
          On Jul 2, Gordon Stewart said:

          >I want to test if $subj exists in $subject
          >
          >if it DOESNT - it is added to the front
          >
          >- If it DOES - Nothing changes...

          This sounds like the job for a hash, not a string with regexes on it!

          for $new_subj (@list_of_subjects) {
          $subjects{$new_subj} = 1;
          }

          or even

          @subjects{ @list_of_subjects } = (1) x @list_of_subjects;

          --
          Jeff "japhy" Pinyan japhy@... http://www.pobox.com/~japhy/
          RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/
          <stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.
          [ I'm looking for programming work. If you like my work, let me know. ]
        • Gordon Stewart
          At 04:43 AM 7/2/03 Jeff japhy Pinyan wrote:- ... Is anyone online ? ive got (text of my log file) :- Subject 1: Good MOrning mummy - [NZ] Subject 2:
          Message 4 of 6 , Jul 2, 2003
          • 0 Attachment
            At 04:43 AM 7/2/03 Jeff 'japhy' Pinyan wrote:-

            >On Jul 2, Gordon Stewart said:
            >
            > >if ($subj !~ m/$subject/i){
            >
            >This checks to see if $subject (as a regex) can be found
            >case-insensitively in $subj. Is this what you are trying to do? Please
            >be more clear.

            Is anyone online ?

            ive got (text of my log file) :-

            Subject 1: ' Good MOrning mummy' - '[NZ]'

            Subject 2: ' Good MOrning mummy' - '[NZ]'

            That is in my log file -

            the [NZ] thing is $subj
            the Good MOrning mummy is $subject


            Now - as $subject does NOT contain [NZ]
            I want $subject to CHANGE to " [NZ] Good MOrning mummy " (no quotes)

            As the regex you quoted above DOES NOT work, Ive changed it to :-



            print "Subject 1: '$subject' - '$subj'\n\n";

            if ($subject !~ m/$subj/i){
            print "TEST 2 - $subj NOT included in $subject\n";

            $subject =~ s/^ +//;
            print "Subject 1A: '$subject' - '$subj'\n\n";
            $subject = "$subj $subject";
            print "Subject 1B: '$subject' - '$subj'\n\n";
            }

            print "Subject 2: '$subject' - '$subj'\n\n";


            It clearly displays the two "Subject" prints - however does NOT print the
            'test' fields..

            Today, Ive tested it (at work - a few emails) & it puts '[NZ]' multiple
            times - one extra each time I reply to the message :-

            RULES :-

            1) If it doesnt containt "[NZ]" - add it to the front of the subject
            2) if it contains "[NZ]" - do nothing..

            pretty simple - & ive been doing regexes for a while
            However im totally bamboozled as to why this simple regex doesnt do what I
            want..

            <getting a "little" fustrated >

            G



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