Reputation: 700
I've got a C styled array (not necessarily null terminated). I'd like to search in it with regex. My code is the following:
const void* Search(const char* startAddress, const char* endAddress, std::regex *re)
{
std::smatch match;
auto ret = std::regex_search(startAddress, endAddress, *re);
In its current form it's working perfectly, however I'd like to know where it found that particular pattern. As soon as I add the match as a parameter, the compiler is unable to find a suiting overloaded function.
I tried making a string_view
out of the region, but the compiler couldn't find any suitable overloaded for those iterators as well.
I'm specifically looking for std::regex
solution. How should I use it?
Upvotes: 2
Views: 755
Reputation: 217850
You need std::cmatch
(for const char*
) instead of std::smatch
(for std::string
).
std::cmatch match;
auto ret = std::regex_search(startAddress, endAddress, match, *re);
Upvotes: 7