有人知道如何在Libreoffice中使用PHP中的str_ireplace
基本功能吗?
我想在我的手机功能中使用。
str_ireplace(search - range of cells, replace - range of cells, text)
或至少str_replace
答案 0 :(得分:1)
我做了非常简单的功能
Function Str_ireplace(Search As Variant, Replace As Variant, Source As String)
Dim Result As String
Dim StartPos As Long
Dim CurrentPos As Long
Dim CurrentSearch As String
Dim CurrentReplace As String
Result = ""
For Row = Lbound( Search, 1 ) To Ubound( Search, 1 )
For Col = LBound(Search, 2) To UBound(Search, 2)
StartPos = 1
CurrentPos = 1
CurrentSearch = Search(Row, Col)
CurrentReplace = Replace(Row, Col)
Result = ""
Do While CurrentPos <> 0
CurrentPos = InStr(StartPos, Source, CurrentSearch)
If CurrentPos <> 0 Then
Result = Result + Mid(Source, StartPos, _
CurrentPos - StartPos)
Result = Result + CurrentReplace
StartPos = CurrentPos + Len(CurrentSearch)
Else
Result = Result + Mid(Source, StartPos, Len(Source))
End If ' Position <> 0
Loop
Source = Result
Next
Next
Str_ireplace = Result
End Function
我以此为例: http://wiki.openoffice.org/wiki/Documentation/BASIC_Guide/Strings_(Runtime_Library)
答案 1 :(得分:0)
试试这个
语法
REPLACE(“文字”;位置;长度;“新文字”)
文本是指将替换部件的文本。
位置是指文本中替换将开始的位置。
长度是要替换的文本中的字符数。
NewText指的是替换Text的文本。
示例强>
=REPLACE("1234567";1;1;"444") returns "444234567". One character at position 1 is replaced by the complete NewText.
https://help.libreoffice.org/Calc/Text_Functions#Example_13
或
SUBSTITUTE(“Text”;“SearchText”;“NewText”;出现次数)
示例强>
= SUBSTITUTE(“123123123”;“3”;“abc”)返回12abc12abc12abc。
= SUBSTITUTE(“123123123”;“3”;“abc”; 2)返回12312abc123。