English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] (Sorry for my last post) lazyness, exceptions?, ocaml syntax rule-of-thumbs
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-09-27 (10:29)
From: Kontra, Gergely <kgergely@m...>
Subject: Re: [Caml-list] (Sorry for my last post) lazyness, exceptions?, ocaml syntax rule-of-thumbs
>> > a function, which checks, whether a string can match a regexp, and
>> > return true or false. Search_forward, again, I think should be return an
>> > option, and not trowing an exception.
>> See Str.string_match : regexp -> string -> int -> bool

>        Str.string_match (Str.regexp ".*\\.html$") filename 0
>        try
>          ignore(Str.search_forward (Str.regexp "\\.html$") filename 0);
>          true
>        with Not_found ->
>          false

Thanks a lot, it was a useful post!
But isn't this functionally so often needed, that it worth to wrap it
into a function?
In many cases it is enough to test, whether a string contains another
string, is it a function for that?

+-[Kontra, Gergely @ Budapest University of Technology and Economics]-+
|         Email: kgergely@mcl.hu,  kgergely@turul.eet.bme.hu          |
|  URL:   turul.eet.bme.hu/~kgergely    Mobile: (+36 20) 356 9656     |
+-------"Olyan langesz vagyok, hogy poroltoval kellene jarnom!"-------+
Magyar php mirror es magyar php dokumentacio: http://hu.php.net

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