Define anchor in regex syntax #1161
Replies: 2 comments 7 replies
-
Hmmm, I found your description quite confusing here. I didn't really understand things (I think) until I read the linked issue. From what I can tell, you want to be able to execute a search at an arbitrary position in a haystack, but provide a way to optionally anchor the search so that all matches begin at the start of the search and/or end at the end of the search. The intended way to do this is indeed I don't think there's anything special about backwards searches here, although there is no "full match" support. That is, this crate has no way of ensuring that a match ends at the end of the search. I believe you'd have to check that after a match. Although I actually think there are cases there that would need support in the search routine itself. For example, if you wanted to do an anchored search at offset To be honest, I'm not really sure what to do here. Do other editors support anchors with respect to selections? |
Beta Was this translation helpful? Give feedback.
-
Thanks for clarifying that sounds good to me!
I don't want to nail you on anything here so if you are not happy with my changes that's ok and we will work from there. I don't expect this to land upstream quickly or at all. Just wanted to get a feeling if you may be open to it so it would make sense for me to build a prototype at all (that may or may not get merged). I am not in a hurry and don't expect anything quickly :) |
Beta Was this translation helpful? Give feedback.
-
I have a usecase where I am accepting arbitrary regex syntax from the user (helix editor user can type search). In this usecase the user will search a subrange (start..end) within a larger haystack I am using regex-automata (or
regex-cursor
:P) to achieve that.However, while this works great for word boundaries and line end/line start anchors there is one feature missing: anchor a search at the start/end of that subrange. I of course know that I could just set
regex-automaton::Input::anchored
but there are a couple issues with that:(\A|x)foo
using\A
as a placeholder for my hypothetical syntax).foo(x|\z)
assuming\z
as a hypothetical placeholder syntax again)I saw a bunch of issues/discussions around something similar but they all boiled down to someone doing this statically or being with using something like
find(&haystack[5..])
which won't work in my case since line breaks and other look around assertions must not match.Some more context: helix-editor/helix#9422 (comment)
Beta Was this translation helpful? Give feedback.
All reactions