camlspotter avatar camlspotter committed 4dc86a0

index_opt and sub_from_to

Comments (0)

Files changed (3)

 #   graph
+   channel
 LIB = spotlib
+open String
+let index_opt s c = try Some (index s c) with Not_found -> None
 let is_prefix ?from:(pos=0) ~prefix:sub str =
   let str_len = String.length str in
   let sub_len = String.length sub in
     else String.sub s 0 (len-1)
   else s
+let sub_from_to s from to_ = 
+  if from > to_ then invalid_arg "sub_from_to";
+  String.sub s from (to_ - from + 1)
 let split_by_newline s =
   let length = String.length s in
   let rec aux st start_pos pos = 
 val index_from_to : string -> int -> int -> char -> int option
 val index_string_from : string -> int -> string -> int (* may raise Not_found *)
+val sub_from_to : string -> int -> int -> string
 val chop_newline : string -> string
 (** [chop_newline s] returns the string [s] w/o the newline chars at the end.
     [chop_newline "hello\r\n" = "hello"]
 val split_at : int -> string -> string * string
 val take : int -> string -> string
 val drop : int -> string -> string
+(** Optionalized *)
+val index_opt : string -> char -> int option
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.