let search_valid ?pwd string =
  try
    let plugins = parsers#get_all in
    (* Try strict plugins first *)
    let compare (_,a) (_,b) = compare b.strict a.strict in
    let plugins = List.sort compare plugins in
    List.iter
      (fun (format,plugin) ->
           log#f 4 "Trying %s parser" format ;
           match try Some (plugin.parser ?pwd string) with _ -> None
              with
                | Some d -> raise (Exit (format,d))
                | None -> () )
      plugins;
    log#f 3 "No format found";
    raise Not_found
  with
    | Exit (format,d) -> format,d