I have an application which outputs queries in the form of copying text to the clipboard.
I've come up with parsing the text into arrays which I then populate back to excel.
the source string contains multiple instances of dates in the format "dd.mm.yyyy" I've been using find/replace on the output column to change this to "dd/mm/yyyy". I was wondering if it would be possible/faster to replace these in the string before parsing to the array by using regex.
strPattern = "(0?[1-9]|[12][0-9]|3[01])[\.](0?[1-9]|1[012])[\.]\d{4}"
strReplace = "$dd\/dd\/dddd"
With regEx
.Global = True
.MultiLine = False
.IgnoreCase = False
.Pattern = strPattern
End With
If regEx.test(sString) Then
sString = regEx.Replace(sString, strReplace)
End If
the end result is not what I was hoping for yet. I think the format of the 'strReplace' is wrong but I don't know regex well enough to fix it. the above was achieved by (too many) hours of web searches.
Thanks for any help.
strReplace = "$1/$2/$3"BTW, you do not need to test the string for a match. If there is no match, the string will not be modified.\d{4}. Use"(0?[1-9]|[12][0-9]|3[01])\.(0?[1-9]|1[012])\.(\d{4})"pattern andstrReplace = "$1/$2/$3"