I'm trying to find multiple regex matches within a string using Vala, but every regex functions I've tried so far (match, match_full, match_all, match_all_full) return only the first match, and I don't get why.
void main() {
Regex exp = /[0-9]{3}/;
string content = "0 12 345 678 9012";
MatchInfo match;
try {
exp.match_all_full (content, -1, 0, 0, out match);
stdout.printf("Found %i coincidences:\n", match.get_match_count ());
for (int i=0; i<match.get_match_count (); i++) {
stdout.printf ("%s\n", match.fetch (i));
}
} catch (GLib.Error e) {
GLib.error ("Regex failed: %s", e.message);
}
}
I also tried this with the same result.