/var/www/xx.yy.com/public_html/files/qjax83: Win.Trojan.B-468 FOUND
/var/www/xx.yy.com/public_html/files/chyusc: Win.Trojan.B-468 FOUND
/var/www/xx.yy.com/public_html/files/7tyskq: Win.Trojan.B-468 FOUND
/var/www/xx.yy.com/public_html/files/bpjeu5: Win.Trojan.MSShellcode-7 FOUND
/var/www/xx.yy.com/public_html/files/q766jv: Win.Trojan.MSShellcode-7 FOUND
/var/www/xx.yy.com/public_html/files/lhie42: Doc.Malware.Valyria-6728957-0 FOUND
This string may be 100 lines or 6 lines it changes every day, I need to get the links of each line after files/ . For example for this string i need to get each link : qjax83,chyusc,7tyskq etc.. Is there an easy way to get these ? I tried to use substring etc but it is not optimal. Maybe possible with regex ?
Dim Text As String = "/var/www/xx.yy.com/public_html/files/qjax83: Win.Trojan.B-468 FOUND"
Dim StartPos, EndPos As Int
StartPos = Text.LastIndexOf("/") + 1
EndPos = Text.IndexOf(":")
Dim Link As String = Text.SubString2(StartPos, EndPos)
Log("link " & Link)
Dim Text As String = "/var/www/xx.yy.com/public_html/files/qjax83: Win.Trojan.B-468 FOUND"
Log(GetLink(Text))
Sub GetLink(Text As String) As String
Dim StartPos, EndPos As Int
StartPos = Text.LastIndexOf("/") + 1
EndPos = Text.IndexOf(":")
Return Text.SubString2(StartPos, EndPos)
End Sub
Dim Text As String = "/var/www/xx.yy.com/public_html/files/qjax83: Win.Trojan.B-468 FOUND"
Log(GetLink(Text))
Sub GetLink(Text As String) As String
Dim StartPos, EndPos As Int
StartPos = Text.LastIndexOf("/") + 1
EndPos = Text.IndexOf(":")
Return Text.SubString2(StartPos, EndPos)
End Sub
Thanks for the example, if it is 1 line it can be done but for multiple lines, it need a more complicated code to get for each line. Am I missing stg ?
Thanks for the example, if it is 1 line it can be done but for multiple lines, it need a more complicated code to get for each line. Am I missing stg ?
Dim Text As String = _
$"/var/www/xx.yy.com/public_html/files/qjax83: Win.Trojan.B-468 FOUND
/var/www/xx.yy.com/public_html/files/chyusc: Win.Trojan.B-468 FOUND
/var/www/xx.yy.com/public_html/files/7tyskq: Win.Trojan.B-468 FOUND
/var/www/xx.yy.com/public_html/files/bpjeu5: Win.Trojan.MSShellcode-7 FOUND
/var/www/xx.yy.com/public_html/files/q766jv: Win.Trojan.MSShellcode-7 FOUND
/var/www/xx.yy.com/public_html/files/lhie42: Doc.Malware.Valyria-6728957-0 FOUND
"$
Dim lstTexts As List = Regex.Split("/var", Text)
For Each Txt As String In lstTexts
If Txt.Length > 0 Then
Log(GetLink(Txt))
End If
Next
B4X:
Sub GetLink(Text As String) As String
Return Text.SubString2(Text.LastIndexOf("/") + 1, Text.IndexOf(":"))
End Sub
Dim m As Matcher
Dim mylines As String=$"/var/www/xx.yy.com/public_html/files/qjax83: Win.Trojan.B-468 FOUND
/var/www/xx.yy.com/public_html/files/chyusc: Win.Trojan.B-468 FOUND
/var/www/xx.yy.com/public_html/files/7tyskq: Win.Trojan.B-468 FOUND
/var/www/xx.yy.com/public_html/files/bpjeu5: Win.Trojan.MSShellcode-7 FOUND
/var/www/xx.yy.com/public_html/files/q766jv: Win.Trojan.MSShellcode-7 FOUND
/var/www/xx.yy.com/public_html/files/lhie42: Doc.Malware.Valyria-6728957-0 FOUND"$
m=Regex.Matcher("/(\w+):",mylines)
Do While m.Find
Log(m.Group(1))
Loop