module Make:
Pcre or Str.| Parameters: |
|
val scan : ?pat:string -> ?rex:R.regexp -> (string -> 'a -> 'a) -> 'a -> string -> 'astr, fold-style.
One of ~pat or ~rex (but not both) are required.
Example: extract a list of all words from stdin:
Kwio.foldlines (scan ~pat:"[A-Za-z]+" cons) [] stdinpat : a string representing a regexprex : a compiled regexpf : function of two params, a substring and an accumulatoracc : initial value for accumulatorstr : string to scanval sub : ?pat:string -> ?rex:R.regexp -> (int -> string -> string) -> string -> stringsub ?pat ?rex f str: ∀i, replace the i'th match of pat or rex with f i x, where x is the text matched.
Exactly one of pat and rex must be provided. Parenthesized
subgroups are not supported.
pat : a string representing a regexprex : a compiled regexpf : function of two params, i the (zero-based) count of how many time f has been called, and x, the text matchedstr : the subject string