ocaml-re icon indicating copy to clipboard operation
ocaml-re copied to clipboard

Clearer documentation for Re.eol

Open hcarty opened this issue 8 years ago • 1 comments

I would expect Re.split Re.(compile eol) "a\nb" to return ["a"; 'b"] but it returns ["a"; "\nb"] instead. If this is intended it would be nice to have this more clearly stated in the documentation.

hcarty avatar Sep 01 '16 21:09 hcarty

This is because eol is more of a zero length assertion. You can use something like Re.(split (compile (char '\n'))) to get the behavior that you want.

I guess we can document which patterns are zero length and how Re.split treats those. I'll start with adding some tests to make sure that we don't accidentally touch this behavior however.

#120

rgrinberg avatar Sep 01 '16 22:09 rgrinberg