caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Str Shortest Match
@ 2003-01-05  4:29 Nicolas Cannasse
  2003-01-07 15:32 ` Dmitry Bely
  0 siblings, 1 reply; 2+ messages in thread
From: Nicolas Cannasse @ 2003-01-05  4:29 UTC (permalink / raw)
  To: OCaml

Hi everyone,

Is there a way to do a shortest regular expression matching using Str ?
In Perl and many RE engines, this is done by using  .*? but it does not
seems to work on Str.

let s = "yayybyyb" in
let r = Str.regexp "a\(.*?\)b" in
Str.search_forward r s 0;
Str.matched_group 1 s;

=> "yybyy" instead of "yy"

Nicolas Cannasse

-------------------
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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] Str Shortest Match
  2003-01-05  4:29 [Caml-list] Str Shortest Match Nicolas Cannasse
@ 2003-01-07 15:32 ` Dmitry Bely
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Bely @ 2003-01-07 15:32 UTC (permalink / raw)
  To: caml-list

"Nicolas Cannasse" <warplayer@free.fr> writes:

> Is there a way to do a shortest regular expression matching using Str ?
> In Perl and many RE engines, this is done by using  .*? but it does not
> seems to work on Str.
>
> let s = "yayybyyb" in
> let r = Str.regexp "a\(.*?\)b" in
> Str.search_forward r s 0;
> Str.matched_group 1 s;
>
> => "yybyy" instead of "yy"

Why not to use Pcre module then?

- Dmitry Bely


-------------------
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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-01-07 15:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-05  4:29 [Caml-list] Str Shortest Match Nicolas Cannasse
2003-01-07 15:32 ` Dmitry Bely

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).