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

[PBML] Regex Help

Expand Messages
  • hdesign
    I ve been trying to figure out what is going on here: the first example returns only $_= My email address is . ; print $_ n ; print Match
    Message 1 of 2 , Aug 23, 1998
    • 0 Attachment
      I've been trying to figure out what is going on here:

      the first example returns > only

      $_='My email address is <<<web@...>.';
      print "$_ \n";
      print "Match worked :$1:\n" if /(<*>)/i;

      and this example returns <<<<>

      $_='My email address is <web@...<<<<>.';
      print "$_ \n";
      print "Match 3 worked :$1:\n" if /(<*>)/i;


      with the regex <*> I understand it as meaning, matching <, then * zero or
      more of the previous characters. I don't see why the first example would
      not return <<> instead of just >.

      If someone could shed some light on this, I would greatly appreciate it.

      Thanks in advance


      ____________________________________________________________
      List Site: http://www.findmail.com/list/perl-beginner/
      To unsubscribe, send to perl-beginner-unsubscribe@...

      FREE group e-mail lists at http://www.findmail.com
    • Jeff Boes
      ... Here s what you want: $_= My email address is . ; print $_ n ; print Match worked :$1: n if / /i; Broken down:
      Message 2 of 2 , Aug 23, 1998
      • 0 Attachment
        On Sun, 23 Aug 1998 17:26:17 -0500, hdesign <hdesign@...> wrote:

        >$_='My email address is <<<web@...>.';
        >print "$_ \n";
        >print "Match worked :$1:\n" if /(<*>)/i;

        Here's what you want:

        $_='My email address is <<<web@...>.';
        print "$_ \n";
        print "Match worked :$1:\n" if /<([^<]*)>/i;


        Broken down:

        < - matches a literal '<'

        () - contains the pattern returned in $1

        []* - defines a class of characters matched as a string

        ^< - matches anything BUT a '<'


        So the pattern says "Match '<', then zero or more characters which aren't a '<',
        and finally a '>'."



        --
        ~~~~~~~~~~~~~~~~|Fare Thee well now, let your
        Jeffery Boes |life proceed by its own design.
        jboes@... |Nothing to tell now, let your
        UIN 3394914 |words be yours, I'm done with mine...

        ____________________________________________________________
        List Site: http://www.findmail.com/list/perl-beginner/
        To unsubscribe, send to perl-beginner-unsubscribe@...

        FREE group e-mail lists at http://www.findmail.com
      Your message has been successfully submitted and would be delivered to recipients shortly.