Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Module Bos.Pat
Named string patterns.
Named string patterns are strings with variables of the form "$(VAR)" where VAR is any (possibly empty) sequence of bytes except ')' or ','. In a named string pattern a "$" literal must be escaped by "$$".
Named string patterns can be used to format strings or to match data.
Type type for variable definitions. Maps pattern variable names to strings.
val subst : ?undef:(string ->string option)->defs->t->t
subst ~undef defs p tries to substitute variables in p by their value. First a value is looked up in defs and if not found in undef. undef defaults to (fun _ -> None).
val format : ?undef:(string -> string)->defs->t-> string
format ~undef defs p substitutes all variables in p with data. First a value is looked up in defs and if not found in undef (defaults to fun _ -> ""). The resulting string is not in pattern syntax (i.e. a literal '$' is represented by '$' in the result).
Matching
Pattern variables greedily match from zero to more bytes from left to right. This is .* in regexp speak.
query ~init p s is like matches except that a matching string returns a map from each pattern variable to its matched part in the string (mappings are added to init, defaults to String.Map.empty) or None if s doesn't match p. If a variable appears more than once in pat the first match is returned in the map.