MCPcopy Create free account
hub / github.com/argotorg/solidity / regex_replace

Function regex_replace

libsolutil/Whiskers.cpp:133–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

131{
132template<class ReplaceCallback>
133std::string regex_replace(
134 std::string const& _source,
135 std::regex const& _pattern,
136 ReplaceCallback _replace,
137 std::regex_constants::match_flag_type _flags = std::regex_constants::match_default
138)
139{
140 std::sregex_iterator curMatch(_source.begin(), _source.end(), _pattern, _flags);
141 std::sregex_iterator matchEnd;
142 std::string::const_iterator lastMatchedPos(_source.cbegin());
143 std::string result;
144 while (curMatch != matchEnd)
145 {
146 result.append(curMatch->prefix().first, curMatch->prefix().second);
147 result.append(_replace(*curMatch));
148 lastMatchedPos = (*curMatch)[0].second;
149 ++curMatch;
150 }
151 result.append(lastMatchedPos, _source.cend());
152 return result;
153}
154}
155
156std::string Whiskers::replace(

Callers 4

replaceMethod · 0.85
stripWhitespaceMethod · 0.85
findSimplificationMethod · 0.85

Calls 3

beginMethod · 0.45
endMethod · 0.45
appendMethod · 0.45

Tested by 1

stripWhitespaceMethod · 0.68