This is so useful and powerful:
#require "str";;
Str.bounded_full_split (Str.regexp "[()]") "toto (titi, tata (et tutu)) vont au parc (en courant)" 1024;;
- : Str.split_result list =
[Str.Text "toto "; Str.Delim "("; Str.Text "titi, tata "; Str.Delim "(";
Str.Text "et tutu"; Str.Delim ")"; Str.Delim ")"; Str.Text " vont au parc ";
Str.Delim "("; Str.Text "en courant"; Str.Delim ")"]
Still finding hidden pearls in the stdlib after so many years!