utils: Add regex_callback_extractor()
This commit is contained in:
orang tua
8b44dd4e94
melakukan
7ca04fbf45
11
utils.cpp
11
utils.cpp
@ -175,3 +175,14 @@ std::string utils::toISODate(time_t t)
|
|||||||
}
|
}
|
||||||
return std::string{result};
|
return std::string{result};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void utils::regex_callback_extractor(std::regex regex, const std::string &input, std::function<void (std::smatch &)> callback)
|
||||||
|
{
|
||||||
|
auto begin = std::sregex_iterator(input.begin(), input.end(), regex);
|
||||||
|
auto end = std::sregex_iterator();
|
||||||
|
for(auto it = begin; it != end; it++)
|
||||||
|
{
|
||||||
|
std::smatch smatch = *it;
|
||||||
|
callback(smatch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
1
utils.h
1
utils.h
@ -60,6 +60,7 @@ template <class T, class U> std::vector<U> getAll(std::multimap<T, U> map, T key
|
|||||||
std::string regex_callback_replacer(std::regex regex, const std::string &input,
|
std::string regex_callback_replacer(std::regex regex, const std::string &input,
|
||||||
std::function<std::string(std::smatch &)> callback);
|
std::function<std::string(std::smatch &)> callback);
|
||||||
|
|
||||||
|
void regex_callback_extractor(std::regex regex, const std::string &input, std::function<void(std::smatch &)> callback);
|
||||||
std::string readCompleteFile(std::string_view filepath);
|
std::string readCompleteFile(std::string_view filepath);
|
||||||
|
|
||||||
inline std::string nz(const char *s)
|
inline std::string nz(const char *s)
|
||||||
|
Memuat…
Reference in New Issue
Block a user