hanickadot / compile-time-regular-expressions

Compile Time Regular Expression in C++
https://twitter.com/hankadusikova
Apache License 2.0
3.22k stars 177 forks source link

Proper way to get result position of search #272

Open jcelerier opened 1 year ago

jcelerier commented 1 year ago

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 commented 1 year ago

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