Hi,
I’m trying do create a macro to “find and replace”, where in the “find” side there are several regex expressions; and in the “replace” side there is only one word. The following macro works for a single regex, but I don’t know how to put multiple regex in the line “oReplace.SearchString =”
Sub ReplaceFormatting
'original code : Alex Savitsky
'modified by : Laurent Godard
Dim oDoc As Object
Dim oReplace As Object
Dim SrchAttributes(0) As New com.sun.star.beans.PropertyValue
Dim ReplAttributes(0) As New com.sun.star.beans.PropertyValue
oDoc = ThisComponent
oReplace = oDoc.createReplaceDescriptor
'Regular expression. Match any text
oReplace.SearchString = "^\s*A"
'Note the & places the found text back
oReplace.ReplaceString = "<&>"
oReplace.SearchRegularExpression=True 'Use regular expressions
oReplace.searchStyles=False
oReplace.searchAll=True 'Do the entire document
REM Now do the work!
oDoc.replaceAll(oReplace)
End Sub
I tried things like this, with no success (gives me a syntax error message):
- oReplace.SearchString = “^\sA", "^\s\d”
- oReplace.SearchString = “^\sA" OR "^\s\d”
- oReplace.SearchString = ("^\sA", "^\s\d")
- oReplace.SearchString = Array("^\sA", "^\s\d")
Is it possible? I’m a layman, so please explain in simple terms.
Thanks,