Hi @Mansour_Dalir ,
To get the position of a substring in the original string, you can use the String.IndexOf method.
Function MultiFinderString(BodyText As String, MultiFind As List(Of String)) As String()
Dim result = New List(Of String) From {BodyText}
Dim p As Integer = 0 ' Start position for searching
For i = 0 To MultiFind.Count - 1
Dim item = MultiFind(i)
result = result.
Where(Function(part) i = MultiFind.Count - 1 OrElse part.Contains(MultiFind(i + 1))).
ToList()
Next
Dim positions = result.
Select(Function(part)
Dim startIndex = BodyText.IndexOf(part, p)
Dim endIndex = startIndex + part.Length - 1
p = endIndex + 1 ' Move start position to after the found part
Return $"{startIndex}-{endIndex}"
End Function).
ToArray()
Return positions
End Function
Best Regards.
Jiachen Li
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.