Hi paolo,

interresting game :)


At the end of this post there's my testing code
am I doing something wrong ?
Perhaps I missed some SearchFlags ?


please find a working modification of your code at the end

in fact you have to loop aver oTextSerach, by starting after the endOfset of your previous result oTextSearch.searchForward(sStrToSearch, aSearchResult.endOffset(rank)+1,Len(sStrToSearch)-1 )

until you have no more result given by
while aSearchResult.subRegExpressions > 0

Please verify this as i didn't take time to verify all things

HTH

Laurent

'----------
Sub Main

oTextSearch = CreateUnoService("com.sun.star.util.TextSearch")

        Dim aSrcOpt As New com.sun.star.util.SearchOptions
        With aSrcOpt
                .searchFlag = com.sun.star.util.SearchFlags.REG_EXTENDED
                .algorithmType = com.sun.star.util.SearchAlgorithms.REGEXP
                .searchString = "[:digit:]+"
        End With

        oTextSearch.setOptions(aSrcOpt)
sStrToSearch = "1 sometext 33 othertext and an other 1 followed by 11 and 654" aSearchResult = oTextSearch.searchForward(sStrToSearch, 0,Len(sStrToSearch)-1 )

        while aSearchResult.subRegExpressions > 0
                        rank = aSearchResult.subRegExpressions - 1
                        iMatchStartPos = aSearchResult.startOffset(rank) + 1
iMatchLen = aSearchResult.endOffset(rank) - aSearchResult.startOffset(rank)
                        sMatchString = Mid(sStrToSearch, iMatchStartPos, 
iMatchLen)
                        MsgBox sMatchString     
aSearchResult = oTextSearch.searchForward(sStrToSearch, aSearchResult.endOffset(rank)+1,Len(sStrToSearch)-1 )
        wend
        
End Sub


--
Laurent Godard <[EMAIL PROTECTED]> - Ing�nierie OpenOffice.org
Indesko >> http://www.indesko.com
Nuxeo CPS >> http://www.nuxeo.com - http://www.cps-project.org
Livre "Programmation OpenOffice.org", Eyrolles 2004


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to