Start New Discussion within our Software Development Community

Hello
Trying to fetch a part of a string with g_regex_split. The string may look like:

"9999 00 00 CC 03 00 CC 00 00 'xxx'"

What I want is to remove everything except:

00 00 CC 03 00 CC 00 00

My idea is (since there is no get_this_part_of_string method) to first split the string with:

d{4}ss (removing the first 4 numbers and the two spaces)

then I'd like to remmove s{3,}'
so the code loks like this:

const GRegex *regfirstSplit =g_regex_new("d{4}ss",  G_REGEX_CASELESS,G_REGEX_MATCH_NEWLINE_CRLF, NULL);
const GRegex *regsecondSplit =g_regex_new("s{3,}'", G_REGEX_CASELESS,G_REGEX_MATCH_NEWLINE_CRLF, NULL);
gchar** array= g_regex_split(regfirstSplit,"9999  00 00 CC 03 00 CC 00 00                           'xxx'",G_REGEX_MATCH_PARTIAL);
gchar** done=g_regex_split(regsecondSplit,*array, G_REGEX_MATCH_PARTIAL);

However, both array and done are NULL.

Does anyone know where I go wrong?

thanks

"9999 00 00 CC 03 00 CC 00 00 'xxx'"

Well: As you have typed it, there is only a single whitespace after "9999". Does this matter?

"\\s{3,}\\'"

Hmmm, 3 Whitespaces? And a single "'"? That's not what your text looks like.
Possibly mistakes?

This question has already been answered. Start a new discussion instead.