Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Substring matching + lookaround weird interaction #128

Open
rgrinberg opened this issue Sep 29, 2016 · 1 comment
Open

Substring matching + lookaround weird interaction #128

rgrinberg opened this issue Sep 29, 2016 · 1 comment

Comments

@rgrinberg
Copy link
Member

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

@vouillon
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants