[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Markus Mottl <markus@o...> |
| Subject: | Re: [Caml-list] PCRE |
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