Function ExtractAllBetween(text As String, startStr As String, endStr As String, Optional delimiter As String = ",") As String
Dim result As String
Dim startPos As Long, endPos As Long
Dim currentPos As Long
Dim temp As String
result = ""
currentPos = 1
Do
startPos = InStr(currentPos, text, startStr)
If startPos = 0 Then Exit Do
startPos = startPos + Len(startStr)
endPos = InStr(startPos, text, endStr)
If endPos = 0 Then Exit Do
temp = Mid(text, startPos, endPos - startPos)
If result = "" Then
result = temp
Else
result = result & delimiter & temp
End If
currentPos = endPos + Len(endStr)
Loop
ExtractAllBetween = result
End Function
こめん
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme