[Gambas-bugtracker] Bug #2644: RegExp not returning submatches

bugtracker at gambaswiki.org bugtracker at gambaswiki.org
Fri Oct 28 21:25:06 CEST 2022


http://gambaswiki.org/bugtracker/edit?object=BUG.2644&from=L21haW4-

Comment #1 by Benoît MINISINI:

This is an API problem, not a bug.

The Count property returns then *number of submatches*, but the first submatch is indexed by 1 (0 being the full matching text).

In other words, you have to write:

  For i As Integer = 0 To hRegex.Count + 1
    Print Subst("Index &1: &2", i, hRegex[i].Text)
  Next

You can see that in the example on the RegExp class wiki help.

As for the double escape, it's standard escaping of Gambas string syntax. Escaping in a Gambas string is not the same thing as escaping inside the regexp, this is why you have to escape twice.

Benoît MINISINI changed the state of the bug to: Rejected.




More information about the Bugtracker mailing list