https://issues.apache.org/ooo/show_bug.cgi?id=122708

            Bug ID: 122708
        Issue Type: DEFECT
           Summary: SearchAlgorithms.REGEXP specific problem
           Product: General
           Version: AOO 3.4.1
          Hardware: All
                OS: Linux
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: scripting
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]

1) run macro testit3 give incorrect result for text
"1111233;2211111;89111112111;89031111190;89111111107"
Results for regular expression "[0-9]{4,12}" is
"1111233,2211111,459111112111,459031111190,459111111107"
expected 1111233,2211111,89111112111,89031111190,89111111107

2) And function regex not work in cell, only run testit3 from menu
Thanks in advance.


REM  *****  regex  *****
Dim a As String

Function regex(a,b,c)

' Attention - made by novice, so can contain bugs

' a - string or cell to search in
' b - regexp string or cell containing regexp string
' c - back-reference number - analogy to \n in regexp syntax


' prepare regexp search options
oTextSearch = CreateUnoService("com.sun.star.util.TextSearch")
oOptions = CreateUnoStruct("com.sun.star.util.SearchOptions")
oOptions.algorithmType = com.sun.star.util.SearchAlgorithms.REGEXP
oOptions.searchString = b
oTextSearch.setOptions(oOptions)

' search first substring
oFound = oTextSearch.searchForward(a, 0, Len(a))

If  oFound.subRegExpressions=0 then
  regex = "No result in that back-reference level"
  Exit Function
Else
  nStart = oFound.startOffset()
  nEnd = oFound.endOffset()
  regex1 = Mid(a, nStart(c) + 1, nEnd(c) - nStart(c))
  tend=Cstr(nEnd(c)+1)
  regex=regex1 
End If
'msgbox oFound.subRegExpressions
do until oFound.subRegExpressions=0
 a=replace(a,tend,Len(a)-Len(regex1)+1)
' msgbox a,tend
 oFound = oTextSearch.searchForward(a, tend, Len(a))
 if  oFound.subRegExpressions=0 then
  exit function
 else
 nStart = oFound.startOffset()
 nEnd = oFound.endOffset()
 regex1 = Mid(a, nStart(c) + 1, nEnd(c) - nStart(c))
 tend=Cstr(nEnd(c)+1)
 regex=CStr(regex)+";"+CStr(regex1)
 End if
loop

End Function

Sub TestIt3()
msgbox
regex("1111233;2211111;89111112111;89031111190;89111111107","[0-9]{4,12}",";")
End Sub

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are the assignee for the bug.

Reply via email to