Код: Выделить всё
REM  *****  BASIC  *****
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()
  regex = Mid(a, nStart(c) + 1, nEnd(c) - nStart(c))
End If
End Functionто выполнив в другой ячейке команду:г.Рубцовск, ул.Пролетарская (здание средней общеобразоват. школы № 13), д.412А
Код: Выделить всё
=REGEX(D3;"\((.*?)\)";0)Код: Выделить всё
(здание средней общеобразоват. школы № 13)