Could Glib::Regex::split_simple return match result as integer?

Can I receive first match result for this method as the integer, not string?

auto match = Glib::Regex::split_simple(
    R"regex(^(\d+)?\s([\w]+\/[\w]+)?)regex",
    subject
);

// match[1] is string

Just want to switch variants for the first match but method return string there. Maybe I forgot about some regex flag? Or Regex class has some methods for that.

No, you will have to manually parse the returned string as an integer using something like g_ascii_string_to_unsigned() or g_ascii_strtoull().

1 Like