I need to use a match function but it must ignore characters like “ą”, “ó”…
for example it should match “Adamów” to “Adamów” and also “Adamow” to “Adamów”
Is it possible to make such a function? I don’t know how…
I need to use a match function but it must ignore characters like “ą”, “ó”…
for example it should match “Adamów” to “Adamów” and also “Adamow” to “Adamów”
Is it possible to make such a function? I don’t know how…
You need to use com.sun.star.util.TextSearch
service, and in struct com.sun.star.util.SearchOptions
passed to its setOptions
you need to put com.sun.star.i18n.TransliterationModulesExtra.IGNORE_DIACRITICS_CTL
in transliterateFlags
.
How to do it? Where i can find it?
This is a sample user-definned function implemented in LibreOffice Basic (its name refers to “Equals Diacritic-Insensitive”):
function EqualsDI(s1 as string, s2 as string) as boolean
dim oOp as new com.sun.star.util.SearchOptions, oSearch as object, r as object
with oOp
.algorithmType = com.sun.star.util.SearchAlgorithms.REGEXP
.transliterateFlags = com.sun.star.i18n.TransliterationModulesExtra.IGNORE_DIACRITICS_CTL
.searchString = "^\Q" & Replace(s1, "\E", "\E\\E\Q", 1, -1, 0) & "\E$"
end with
oSearch = CreateUnoService("com.sun.star.util.TextSearch")
oSearch.setOptions(oOp)
r = oSearch.searchForward(s2, 0, Len(s2))
EqualsDI = r.subRegExpressions = 1
end function
Or a better variant:
function EqualsDI(s1 as string, s2 as string) as boolean
dim oLoc as new com.sun.star.lang.Locale, oTr as object
oTr = CreateUnoService("com.sun.star.i18n.Transliteration")
oTr.loadModule(com.sun.star.i18n.TransliterationModulesExtra.IGNORE_DIACRITICS_CTL, oLoc)
EqualsDI = oTr.compareString(s1, s2) = 0
end function
It can be used in Calc like
=EqualsDI(A1; A2)
and when A1
has Adamów
, and A2
has Adamow
, it will give TRUE
.
i got error when i try to run your better variant
“The argument is not optional.”
You did not write what is your formula actually; and on which line the error is. Also it’s unclear if you could make some typing error in the macro; and also what is in the cells the formula may refer to. So nothing that I can answer.
i can’t run
=EqualsDI(A1; A2)
beacuse when i try to run macron it throw basic language error
Could you post a link to screenshot showing your cells, the error message, and the macro code? You may post the screenshot e.g. to https://imgur.com.