Just if someone needs it, I've added an optional argument submatchindex that 
will return the matches of a given submatch.

PRIVATE FUNCTION FindAll(subj AS String, pattern AS String, OPTIONAL 
submatchindex AS Integer = 0) AS String[]
        DIM re AS Regexp
        DIM matches AS NEW String[]
        re = NEW Regexp(subj, pattern)
        DO WHILE re.offset >= 0 AND subj <> ""
                IF submatchindex = 0 THEN 
                        matches.push(re.Text)
                ELSE
                        matches.push(re.SubMatches[submatchindex].Text)
                END IF
                IF Len(subj) > Len(re.text) THEN
                        subj = Mid(subj, re.offset + Len(re.text) + 1)
                ELSE
                        subj = ""       
                END IF
                IF subj <> "" THEN re.exec(subj)
        LOOP
        RETURN matches
END

Best regards,
-- 
Markus Schatten, MSc
Faculty of Organization and Informatics
Varaždin, Croatia
http://www.foi.hr

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to