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

Function regex_split

src/engine/modules/regex.cpp:34–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32*/
33
34LIST * regex_split( FRAME * frame, int flags )
35{
36 LIST * args = lol_get( frame->args, 0 );
37 OBJECT * s;
38 OBJECT * separator;
39 regexp * re;
40 const char * pos, * prev;
41 LIST * result = L0;
42 LISTITER iter = list_begin( args );
43 s = list_item( iter );
44 separator = list_item( list_next( iter ) );
45
46 re = regex_compile( separator );
47
48 prev = pos = object_str( s );
49 while ( regexec( re, pos ) )
50 {
51 result = list_push_back( result, object_new_range( prev, int32_t(re->startp[ 0 ] - prev) ) );
52 prev = re->endp[ 0 ];
53 /* Handle empty matches */
54 if ( *pos == '\0' )
55 break;
56 else if ( pos == re->endp[ 0 ] )
57 pos++;
58 else
59 pos = re->endp[ 0 ];
60 }
61
62 result = list_push_back( result, object_new( pos ) );
63
64 return result;
65}
66
67/*
68rule replace (

Callers

nothing calls this directly

Calls 8

lol_getFunction · 0.85
list_beginFunction · 0.85
regex_compileFunction · 0.85
object_strFunction · 0.85
regexecFunction · 0.85
list_push_backFunction · 0.85
object_new_rangeFunction · 0.85
object_newFunction · 0.85

Tested by

no test coverage detected