[Gambas-user] Regexp Submatches

Nathan Neff nathan.neff at ...626...
Wed Jun 25 16:21:29 CEST 2008


Hello,

I would like some help using the Submatches property of the Regexp feature
in Gambas.

For example, I want to find all non-whitespace characters in the string
"Gambas", and
iterate through them.  I tried code like this:

DIM rege AS NEW Regexp
  DIM i AS Integer

  ' The \S is a non-whitespace character
  ' See http://www.perl.com/doc/manual/html/pod/perlre.html
  ' The other left \ is to escape the right \, so that Gambas isn't
confused.
  rege.Compile("(\\S)")
  rege.Exec("gambas")

  FOR i = 1 TO rege.SubMatches.count
    Message(rege.SubMatches[i].Text)
  NEXT

But I can only get it to print out the "g" character.

I want to use more complex regular expressions, which is why I'm not using
the LIKE and
SPLIT functions of the String object.

Can anyone help?  I'm running Gambas 2.0.0 on Ubuntu Linux
Thanks,
--Nate



More information about the User mailing list