caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Markus Mottl <markus@oefai.at>
To: Oleg <oleg_inconnu@myrealbox.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] PCRE
Date: Sun, 29 Dec 2002 19:41:30 +0100	[thread overview]
Message-ID: <20021229184130.GA11651@fichte.ai.univie.ac.at> (raw)
In-Reply-To: <200212291042.49347.oleg_inconnu@myrealbox.com>

On Sun, 29 Dec 2002, Oleg wrote:
> I'm new to PCRE. Can anyone explain to me why the output of
> 
> # open Pcre;;
> # version;;
> - : string = "3.4 22-Aug-2000"
> # full_split ~pat:"^(\\w+)(,(\\w+))*$" "a,b,c,d";;
> - : Pcre.split_result list =
> [Delim "a,b,c,d"; Group (1, "a"); Group (2, ",d"); Group (3, "d")]
> 
> does not contain Group(3, "b") and Group(3, "c") ?

Note that using "split" instead of "full_split" produces this list:

  - : string list = [""; "a"; ",d"; "d"]

This is absolutely correct Perl-behaviour.

"full_split" is actually the same, but it also allows you to access
matched substrings. Grouped subpatterns can only capture substrings once
(i.e. the last one if several are possible)!

> Similarly, I expected 
> 
> # full_split ~pat:"S(a\\d)+" "Sa1a2";;
> - : Pcre.split_result list = [Delim "Sa1a2"; Group (1, "a2")]
> 
> to produce [Delim "Sa1a2"; Group(1, "a1"); Group (1, "a2")]
> 
> The above uses the latest pcre-ocaml-4.31.0.

The same applies here: the behaviour of PCRE-OCaml is correct
wrt. Perl-semantics.

Regards,
Markus Mottl

-- 
Markus Mottl                                             markus@oefai.at
Austrian Research Institute
for Artificial Intelligence                  http://www.oefai.at/~markus
-------------------
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-12-29 18:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-29 15:42 Oleg
2002-12-29 18:41 ` Markus Mottl [this message]
  -- strict thread matches above, loose matches on Subject: below --
2002-12-08 21:22 [Caml-list] another question about pcre_exec onlyclimb
2002-12-08 21:09 ` [Caml-list] pcre onlyclimb
2002-12-08 13:51   ` Markus Mottl

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=20021229184130.GA11651@fichte.ai.univie.ac.at \
    --to=markus@oefai.at \
    --cc=caml-list@inria.fr \
    --cc=oleg_inconnu@myrealbox.com \
    /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).