Module StrExtras


module StrExtras: sig  end
String functions



String construction


val combine : string list -> string
Concatenates a list of strings with a blank seperator
val map : (char -> char) -> string -> string
Like Array.map, for strings. Returns a newly allocated transformed string.


String manipulation



Most of these functions return newly allocated strings that are modified versions of their arguments

val first_word : string -> string
Returns the first word of a string
val cut_first_char : string -> string
Cuts off the first character of a string and returns the rest
val cut_first_n : string -> int -> string
Cuts off the first n characters of a string and returns the rest.
val cut_last_char : string -> string
Cuts off the last character of a string and returns the rest
val cut_last_n : string -> int -> string
Cuts off the last n characters of a string and returns the rest
val cut_first_word : string -> string
Cuts off the first word of a string and returns the rest
val split_at : str:string -> sep:char -> string
Returns everything after the character
val chomp : string -> string
Remove all trailing whitespace
val map_inplace : (char -> char) -> string -> unit
Like map, but modifies the argument string.


Capitalization


val uppercase : string -> string
Like String.uppercase, but locale-dependant
val lowercase : string -> string
Like String.lowercase, but locale-dependant
val capitalize : string -> string
Like String.capitalize, but locale-dependant
val uncapitalize : string -> string
Like String.uncapitalize, but locale-dependant


String searching


val first_of : string -> string -> int
first_of needle haystack returns the position of the first occurance in haystack of a character in needle. Like C strcspn().
Raises Not_found if no characters in needle are in haystack
val first_of_from : string -> string -> int -> int
first_of_from needle haystack pos returns the position of the first occurance in haystack (Starting at pos) of a character in needle.
Raises Not_found if no characters in needle are in haystack
val first_not_of : string -> string -> int
first_not_of needle haystack returns the position of the first occurance in haystack of a character that's not also in needle. Like C strspn().
Raises Not_found if all characters in needle are in haystack
val first_not_of_from : string -> string -> int -> int
first_not_of_from needle haystack pos returns the position of the first occurance in haystack (Starting at pos) of a character that's not also in needle.
Raises Not_found if all characters in needle are in haystack
val prefix : string -> string -> bool
prefix pref str returns true if str starts with pref.
val suffix : string -> string -> bool
suffix suf str returns true if str starts with suf.
val index_substr : string -> string -> int
index_str needle haystack returns the position in haystack where needle starts.
Raises Not_found if the substring isn't present.
val index_substr_from : string -> string -> int -> int
index_substr_from needle haystack pos returns the position in haystack where needle starts, starting looking at pos.
Raises
val match_substr : string -> string -> int -> bool
match_substr substr str pos returns true if str contains substr at position pos
Raises Invalid_argument if pos is out of range