matchAll()

Data / String Functions

Description

Uses a regular expression to find all matches in a string.

Syntax

std::vector<std::vector<std::string>> matchAll(std::string s, std::string pattern)

Parameters

NameTypeDescription
sstd::stringthe string to search
patternstd::stringregular expression pattern

Returns

std::vector>

Related

Under the Hood

From Processing.h:

inline std::vector<std::vector<std::string>> matchAll(const std::string& s, const std::string& pat) { std::vector<std::vector<std::string>> out; std::regex re(pat); auto it=std::sregex_iterator(s.begin(),s.end(),re), end=std::sregex_iterator(); for(;it!=end;++it){ std::vector<std::string> row; for(auto& x:*it) row.push_back(x.str()); out.push_back(row); } return out; }