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

Proper way to get result position of search #272

Open
jcelerier opened this issue Oct 6, 2022 · 1 comment
Open

Proper way to get result position of search #272

jcelerier opened this issue Oct 6, 2022 · 1 comment

Comments

@jcelerier
Copy link
Contributor

Hello,
given e.g.

auto res = ctre::search<"\\.[0-9]+$">("foo.123");

with std::regex one can get the "foo" part with the prefix() method of std::match_results.
Is there a correct way to have the same functionality with ctre? One cannot just compare the iterator of to_view().begin() with the original string's iterator as it is UB to compare iterators of different objects and comparing the pointers to the underlying data() is error-prone

@wuyingnan
Copy link

I think you can take a look at this. #157
The author said

ctre::range returns a range of matches which are equivalent of a cycling with repeated ctre::search calls

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