module Xstr_search:sig
..end
exception Replace_phrase of (int * string)
see 'replace_char' and 'replace_string'
val index_of_substring_from : string -> int -> string -> int
index_of_substring_from s k_left substr: finds the leftmost index >= k_left where 'substr' occurs within s or raises Not_found.
val rindex_of_substring_from : string -> int -> string -> int
eindex_of_substring_from s k_right substr: finds the rightmost index <= k_right where 'substr' occurs within s or raises Not_found.
val index_of_substring : string -> string -> int
index_of_substring s substr: finds the leftmost index where 'substr' occurs within s or raises Not_found.
val rindex_of_substring : string -> string -> int
eindex_of_substring s substr: finds the rightmost index where 'substr' occurs within s or raises Not_found.
val contains_substring : string -> string -> bool
contains_substring s substr: true iff substr occurs in s
val contains_substring_from : string -> int -> string -> bool
contains_substring_from s k_left substr: true iff substr occurs in s at index k_left or later
val rcontains_substring_from : string -> int -> string -> bool
rcontains_substring_from s k_right substr: true iff substr occurs in s at index k_right or earlier
val indexlist_of_substring : string -> string -> int list
indexlist_of_substring s substr: Returns a list of all indexes of substrings substr in s
val rev_concat : string -> string list -> string
rev_concat s l = String.concat s (List.rev l)
val replace_char : string -> (char -> int -> string) -> string
replace_char s rule:
replaces characters in s according to rule.
rule c k = s' means: replace character c where c = s.k
by s'
The rule may raise Match_failure or Not_found in which case
the character is not replaced.
It may raise Replace_phrase (l,s') which means that the l
characters at k should be replaced by s'.
EXAMPLE:
k+1
)))
else
raise Not_found
end)val replace_substring : string -> string list -> (string -> int -> string) -> string
replace_substring s substrlist rule: replaces all occurences of substrings in 's' which are enumerated in 'substrlist' by applying 'rule'. rule t k = t': means that substring t at position k is replaced by t' The rule may raise Match_failure or Not_found in which case the character is not replaced. It may raise Replace_phrase (l,s') which means that the l characters at k should be replaced by s'.
EXAMPLE:
"<"; ">"; "&"
(fun s k -> match s with
"<" -> "<"
| ">" -> ">"
| "&" -> "&")