MCPcopy Create free account
hub / github.com/SpartanJ/eepp / gsub

Method gsub

src/eepp/system/patternmatcher.cpp:187–203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

185}
186
187std::string PatternMatcher::gsub( const char* text, const char* replace ) {
188 PatternMatcher::Match ms( *this, text );
189 std::string res;
190 while ( ms.subst( res ) ) {
191 for ( const char* ptr = replace; *ptr; ++ptr ) {
192 if ( *ptr == '%' ) {
193 ++ptr;
194 int ngroup = (int)*ptr - (int)'0';
195 res += ms.group( ngroup );
196 } else {
197 res += *ptr;
198 }
199 }
200 ms.next();
201 }
202 return res;
203}
204
205std::string PatternMatcher::gsub( const std::string& text, const std::string& replace ) {
206 return gsub( text.c_str(), replace.c_str() );

Callers 3

loadLayoutFromStringMethod · 0.80
loadLayoutFromMemoryMethod · 0.80
loadLayoutFromStreamMethod · 0.80

Calls 4

substMethod · 0.80
groupMethod · 0.80
c_strMethod · 0.80
nextMethod · 0.45

Tested by

no test coverage detected