Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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:,          |
|  URL:    Mobile: (+36 20) 356 9656     |
+-------"Olyan langesz vagyok, hogy poroltoval kellene jarnom!"-------+
Magyar php mirror es magyar php dokumentacio:

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: