I have an excel file with urls of type
http://test.example.com/anything…
i want to make it
http://test.example.com
does someone know the regex i should use ? (i got a macro in VB for the replace, i just need the regex)
thanks
Public Function SearchNReplace1(Pattern1 As String, _
Pattern2 As String, Replacestring As String, _
TestString As String)
Dim reg As New RegExp
reg.IgnoreCase = True
reg.MultiLine = False
reg.Pattern = Pattern1
If reg.Test(TestString) Then
reg.Pattern = Pattern2
SearchNReplace1 = reg.Replace(TestString, Replacestring)
Else
SearchNReplace1 = TestString
End If
End Function
from:
([a-z]+://[a-z0-9.-]+)[^ ]*to:\1This will eat enything after the domain name until encountees a space or end of string. Please give more details if this one does not suit you.
If you need ipv6 addresses as hosts you have to allow
[]:character too:from:
([a-z]+://[a-z0-9.\[\]:-]+)[^ ]*to:\1