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

need a way to match at beginning of string when start > 0 #80

Open
timotheecour opened this issue Oct 30, 2020 · 5 comments
Open

need a way to match at beginning of string when start > 0 #80

timotheecour opened this issue Oct 30, 2020 · 5 comments

Comments

@timotheecour
Copy link
Contributor

timotheecour commented Oct 30, 2020

following #67, ^ now refers to position 0 (instead of start) even if start > 0.
We need a way to allow matching at position = start (ie emulate the behavior of ^ before #67).

As suggested here #64 (comment), how about adding a bool flag, treatStartAsStart, with perhaps a better name?

note

@nitely
Copy link
Owner

nitely commented Oct 30, 2020

What about passing a slice? or an openArray?

IIRC, match behaves differently from find for ^ when start > 0

Yeah, it does. Maybe it needs fixing.

@timotheecour
Copy link
Contributor Author

What about passing a slice? or an openArray?

that would prevent using context eg lookaround:
(?=T|^S)suffi
note that this currently gives Invalid lookaround, expected closing symbol. Beware lookaround is currently limited to match one single character but that's a limitation that (hopefully) will be lifted in the future (as in D's regex + other libs), so openArray would not help there.

Note that supporting openArray is independently useful.

@nitely
Copy link
Owner

nitely commented Oct 31, 2020

Oh, a special case. I'll wait for re/nre to implement it anyway.

btw, is there a regex engine that has this feature? I tried Python's re, but it works just like re/nre.

@timotheecour
Copy link
Contributor Author

I'm not sure; but supporting openArray would indeed help in the meantime

@nitely nitely added feature New feature postponed upstream and removed feature New feature labels Nov 3, 2020
@auxym
Copy link

auxym commented Dec 13, 2022

I think this would be a useful feature (allowing ^ to match at position start instead of fixed 0), whether as default behavior or with a flag.

Edit: Or alternatively, find/match procs that accept openArray[char] for the input string.

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

No branches or pull requests

3 participants