in reply to Re: Re: parsing question
in thread parsing question

Unfortunally, it only explains what it does, but it doesn't explain why it does so. Perhaps the most subtle part of the regex is (?>\s+).

Can you explain why it uses "no backtracking"? ;-)

Abigail

Replies are listed 'Best First'.
Re: Re: parsing question
by allolex (Curate) on Sep 12, 2003 at 13:06 UTC

    I would love to know why you did what you did with that regex. There are probably a lot of monks in the Monastery who could learn something from you and just need a little push in the right direction. :)

    --
    Allolex

      #!/usr/bin/perl use strict; use warnings; while (<DATA>) { chomp; print "with (?>): '$_' matches\n" if /_test(?>\s+)(?!<)/; print "without (?>): '$_' matches\n" if /_test\s+(?!<)/; } __DATA__ _test foo _test < _test < _test<

      Running this gives:

      with (?>): '_test foo' matches without (?>): '_test foo' matches without (?>): '_test <' matches

      Abigail

2Re: parsing question
by bart (Canon) on Sep 13, 2003 at 10:31 UTC
    I'm sure you're familiar with the "cut" operator, Abigail, but most of the other people here will find it largely underdocumented. So I dare to feel free to point towards the draft of a book on regular expressions that the same perlmonk is writing, who also wrote YAPE::Regex::Explain (actually, he wrote the whole YAPE suite).

    I personally like the draft of book very much, and so, I like to plug it whenever I can. So here's the URL: http://japhy.perlmonk.org/book/. Check out chapter 8 for the "cut" operator — every chapter is a separate download, roughly around 12 pages each, either in MS Word or in PDF format. Recommended.