[Gambas-user] I don't think regexp is working correctly, wrong number of fields are returned

T Lee Davidson t.lee.davidson at gmail.com
Mon Oct 9 02:34:20 CEST 2023


On 10/8/23 19:56, Brian G wrote:
> When Using regexp, the last field is never captured, unless I am just doing something wrong?

You are. ;-)  I can't count how many times I've done similarly.

Try this:
[code]
Sub printReg(MyReg As RegExp)

     Print "Count =";; MyReg.Count
     For i As Integer = 0 To MyReg.Count ' Not Count - 1
         Print "Field";; i;; "=";; Quote(MyReg[i].text)
     Next

End
[/code]

https://gambaswiki.org/wiki/comp/gb.pcre/regexp/_get :
"The index of the first submatch is 1, and the index of the last one is the Count property."


-- 
Lee



More information about the User mailing list