caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Pixel <pixel@mandrakesoft.com>
To: Jerome Vouillon <vouillon@pps.jussieu.fr>
Cc: John Skaller <skaller@ozemail.com.au>, caml-list@inria.fr
Subject: Re: [Caml-list] Regarding regular expressions
Date: 07 Aug 2002 14:23:12 +0200	[thread overview]
Message-ID: <lyeldaeu33.fsf@leia.mandrakesoft.com> (raw)
In-Reply-To: <20020807073600.GA31615@strontium.pps.jussieu.fr>

Jerome Vouillon <vouillon@pps.jussieu.fr> writes:

[...]

> > So, nearly half of all perl scripts on CPAN that use regular expressions
> > make use of the backreference feature.  IMO this argues strongly in
> > favor of supporting backreferences in C++.  (Backreferences can only be
> > handled by a backtracking NFA engine, IIRC.)
> 
> What he means by backreference is a way to refer to a submatch.  For
> instance, with the regular expression "^([^ ]*) *([^ ]*)", the
> backreference "$1" will refer to the substring matched by the first
> parenthesed subexpression "([^ ]*)".  As long as the references do not
> occur in the regular expression itself, they can be handled perfectly
> well with a DFA engine.  So, the numbers above do not prove anything.

agreed.

Here are the numbers I get (only scanning perl 5.8.0, not CPAN):

% cd /usr/lib/perl5/5.8.0
% find -name "*.p[lm]" | xargs perl -ne 'print "$ARGV: $_" if /[=!]~\s*[^ty ]/' | wc -l
   2640
% find -name "*.p[lm]" | xargs perl -ne 'print "$ARGV: $_" if /[=!]~\s*[^ty ]/' | perl -ne 'print if /\\[1-9]\D/' | wc -l
      3
% find -name "*.p[lm]" | xargs perl -ne 'print "$ARGV: $_" if /[=!]~\s*[^ty ]/' | perl -ne 'print if /\\[1-9]\D/'
./ExtUtils/MM_Win32.pm:      while ($libs =~ s/(?:^|\s)(("?)-L.+?\2)(?:\s|$)/ /) {
./Pod/Text/Overstrike.pm:     $text =~ s/(.)[\b]\1/$1/g;
./Test.pm:          (undef, $regex) = ($expected =~ m,^ m([^\w\s]) (.+) \1 $,sx)) {

> - how often are backreferences used within a pattern?

I get 3 / 2640 = 0.1%
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


  reply	other threads:[~2002-08-07 12:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-07  5:02 John Skaller
2002-08-07  7:36 ` Jerome Vouillon
2002-08-07 12:23   ` Pixel [this message]
2002-08-07 14:41   ` [Caml-list] Three way comparaisons Diego Olivier Fernandez Pons
2002-08-07 15:22     ` Luc Maranget
2002-08-08 11:44       ` Diego Olivier Fernandez Pons

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=lyeldaeu33.fsf@leia.mandrakesoft.com \
    --to=pixel@mandrakesoft.com \
    --cc=caml-list@inria.fr \
    --cc=skaller@ozemail.com.au \
    --cc=vouillon@pps.jussieu.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).