Could Glib::Regex::split_simple return match result as integer? (original) (raw)

September 16, 2024, 10:29am 1

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.

pwithnall (Philip Withnall) September 16, 2024, 11:06am 2

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().

system (system) Closed October 16, 2024, 11:06am 3

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.