Oups, I confirm it is a bug appearing when we have separated formatting_gen to formatting_lit in the implementation of formats to handle Format constructions like "@{<%s>" and "@[" that collides with scanf constructions like "%s@{" and "%s@[". I attach a patch (+ 6 lines) that fix the problem, if somebody have time to integrate it... Sorry. Benoît. Le 21/02/2015 10:55, Gabriel Scherer a écrit : > This seems to be a regression caused by the reimplementation of format > strings in 4.02; some "stop after this character" indications are > supported, but some other fail (when they correspond to valid Format > specifications). Would you mind opening a but report ( > http://caml.inria.fr/mantis/ )? > > On Fri, Feb 20, 2015 at 8:28 PM, Milan Stanojević > wrote: > > I want to parse a bash like sequence string, for example > "some-thing{1..20}", and extract the string before first { and then > two numbers inside. > > I tried this first > utop # Scanf.sscanf "some-thing{1..3}" "%s{%d..%d}" (fun s n1 n2 > -> s,n1,n2);; > Exception: End_of_file. > > Then I realized %s is special and needs scanning indication > (character @). > > So I tried that but I get the same error > utop # Scanf.sscanf "some-thing{1..3}" "%s@{%d..%d}" (fun s n1 n2 > -> s,n1,n2);; > Exception: End_of_file. > > But if I use some other character as end of string indication then > it works. > utop # Scanf.sscanf "some-thingI{1..3}" "%s@I{%d..%d}" (fun s n1 n2 -> > s,n1,n2);; > - : bytes * int * int = ("some-thing", 1, 3) > > It seems '{' is somehow special but I can't find anything in the docs > about this. > Can someone explain what is going on here? > > Thanks! > > > p.s. At the end I solved my thing by using a range > > utop # Scanf.sscanf "some-thing{1..3}" "%[a-z-]{%d..%d}" (fun s n1 n2 > -> s,n1,n2);; > - : bytes * int * int = ("some-thing", 1, 3) > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa.inria.fr/sympa/arc/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > >