compile-time-regular-expressions icon indicating copy to clipboard operation
compile-time-regular-expressions copied to clipboard

Proper way to get result position of search

Open jcelerier opened this issue 3 years ago • 1 comments
trafficstars

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

jcelerier avatar Oct 06 '22 23:10 jcelerier

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

wuyingnan avatar Oct 19 '22 05:10 wuyingnan