MCPcopy Create free account
hub / github.com/boostorg/build / regex_replace

Function regex_replace

src/engine/modules/regex.c:85–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83*/
84
85LIST * regex_replace( FRAME * frame, int flags )
86{
87 LIST * args = lol_get( frame->args, 0 );
88 OBJECT * s;
89 OBJECT * match;
90 OBJECT * replacement;
91 regexp * re;
92 const char * pos;
93 string buf[ 1 ];
94 LIST * result;
95 LISTITER iter = list_begin( args );
96 s = list_item( iter );
97 iter = list_next( iter );
98 match = list_item( iter );
99 iter = list_next( iter );
100 replacement = list_item(iter );
101
102 re = regex_compile( match );
103
104 string_new( buf );
105
106 pos = object_str( s );
107 while ( regexec( re, pos ) )
108 {
109 string_append_range( buf, pos, re->startp[ 0 ] );
110 string_append( buf, object_str( replacement ) );
111 pos = re->endp[ 0 ];
112 }
113 string_append( buf, pos );
114
115 result = list_new( object_new( buf->value ) );
116
117 string_free( buf );
118
119 return result;
120}
121
122/*
123rule transform ( list * : pattern : indices * )

Callers

nothing calls this directly

Calls 11

lol_getFunction · 0.85
list_beginFunction · 0.85
regex_compileFunction · 0.85
string_newFunction · 0.85
object_strFunction · 0.85
regexecFunction · 0.85
string_append_rangeFunction · 0.85
string_appendFunction · 0.85
list_newFunction · 0.85
object_newFunction · 0.85
string_freeFunction · 0.85

Tested by

no test coverage detected