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

Substring matching + lookaround weird interaction

Open rgrinberg opened this issue 9 years ago • 1 comments

Substring matches are able to "peek" outside of substrings when lookaround assertions are start/begin of the re. Here's an example of what I mean:

utop[19]> let re = Re.(compile @@ seq [bol ; str "xxx"]);;
val re : Re.re = <abstr>
utop[20]> Re.execp ~pos:1 ~len:3 re "yxxx";;
- : bool = false
utop[21]> Re.execp ~pos:1 ~len:3 re "\nxxx";;
- : bool = true

This means that there's no way for the user to independently match a substring. Not really broken but counter intuitive IMHO.

cc @Drup

rgrinberg avatar Sep 29 '16 03:09 rgrinberg

That's what we want, for instance if we want to split a string at each beginning of line.

But indeed, there is no way to tell Re to match without look outside a substring, which might be convenient when using a string as a buffer.

vouillon avatar Dec 13 '16 09:12 vouillon