do they all end in .com
Ok so I wasn't sure where to ask this but I guess there may be a program that can help me, I have a txt file with a url in each line. Over 37,000 of them. Like this
1. www.blablabl.com
2. www.moreblabl*****m
3. www.bl*****m
37238. www.blabl*****m
Im trying to find a way to remove each number and fall stop for everyline, I would imagine there is a simple way to do it but for the life of me I can't figure out a way. Any ideas?
Last edited by silentrunner2; 06-27-2012 at 01:22 PM.
My ProjectsCOD Ghost Extreme Edition - https://www.mpgh.net/forum/723-call-d...rt-system.html
Account Creator Extreme - https://www.mpgh.net/forum/33-visual-...-websites.html
Don't Ask For Thanks Earn It
You: "Please Give Thanks"
Me: "...................No"
do they all end in .com
My ProjectsCOD Ghost Extreme Edition - https://www.mpgh.net/forum/723-call-d...rt-system.html
Account Creator Extreme - https://www.mpgh.net/forum/33-visual-...-websites.html
Don't Ask For Thanks Earn It
You: "Please Give Thanks"
Me: "...................No"
Best way: Regex.
Another way, split by "." ->
dim lines() as String = System.Text.RegularExpressions.Regex.Split(fullTex t,"\n")
dim newText as string = ""
for i = 0 to lines.count - 1
dim split as string = lines(i).split(".")(0)
dim line as string = lines(i).substring(split.length+2,lines(i).length - split.length-2)
newText &= line & vbnewline
next
Noob way, but no further time to post a better one.
Enum list and check?
Or, I got this wrong :S
Code:Public Function deleteNumbers(ByVal Input As String) as string Dim lines() As String = System.Text.RegularExpressions.Regex.Split(Input, "\n") Dim sB As New System.Text.StringBuilder For i = 0 To lines.count - 1 Dim split As String = lines(i).split(".")(0) Dim line As String = lines(i).substring(split.Length + 2, lines(i).length - split.Length - 2) sB.AppendLine(line) Next Return sB.ToString End FunctionCode:using sR as new system****.streamreader("yourfile.txt") dim newText as string = deleteNumbers(sR.readtoend) using sW as new system****.streamwriter("updated.txt") sW.write(newText) end using end using
Way better method...
Code:Public Function delNumbers(ByVal Input As String) Return System.Text.RegularExpressions.Regex.Replace(Input, "\d+. ", "") End Function
Last edited by Blubb1337; 06-28-2012 at 09:31 AM.
@Blubb1337
ArgumentOutOfRangeException is what i get.
Plus Dim lines() As String is an array but your for loop is treating it as a list. It should be lines.Length not count.
Anyhoo
@silentrunner2
Heres what iv come up with. It reads it as one big string. Tested it on a text file 300,000 plus lines. Really fast on my system.
It will replace your original text file so backup the file before you try if you decide to use this method.
Code:Imports System.[IO]Code:Dim Opn As New OpenFileDialog If Opn.ShowDialog = DialogResult.OK Then Dim SR As New StreamReader(Opn.FileName) Dim tmp As String = SR.ReadToEnd Dim tmpPath As String = Path.GetTempFileName Dim SW As New StreamWriter(tmpPath) SR.Close() Dim i As Integer = 0, j = tmp.Length, _End Do i = tmp.IndexOf("www", i) If i <> -1 Then _End = tmp.Substring(i, If((j - i > 30), 30, j - i)).IndexOf(ChrW(10)) If _End <> -1 Then SW.WriteLine(tmp.Substring(i, _End)) End If i += 1 End If Loop Until i = -1 SW.Close() File.Delete(Opn.FileName) File.Move(tmpPath, Opn.FileName) MessageBox.Show("DONE") End If
So, no Number Enum Check then?
(Don't know how It would be make in VB.Net)
Just shut your cunt and let the real men handle it.
Simple way:
Call it like so:Code:Public Shared Sub FormatFile(ByVal inputFile As String, ByVal outputFile As String) Using sReader As New IO.StreamReader(inputFile) Using sWriter As New IO.StreamWriter(outputFile) Dim line As String = String.Empty Dim sections As String() While Not sReader.EndOfStream line = sReader.ReadLine() sections = line.Split(New Char() {" "c}, 2) sWriter.WriteLine(CType(If(sections.Length = 2, sections(1), sections(0)), String)) End While End Using End Using End Function
Or if you want to be a shitcunt and not worry about memory:Code:FormatFile("B:\fuckedformatting.txt", "B:\niceformatting.txt")
Or use the above code to manipulate the text in memory. Either way.Code:Dim original As String() = IO.File.ReadAllLines("yourfile") IO.File.WriteAllLines("yourfile", Array.ConvertAll(original, Function(s) s.Split(New Char() { " "c }, 2)(1)))
You can win the rat race,Originally Posted by Jeremy S. Anderson
But you're still nothing but a fucking RAT.
++Latest Projects++
[Open Source] Injection Library
Simple PE Cipher
FilthyHooker - Simple Hooking Class
CLR Injector - Inject .NET dlls with ease
Simple Injection - An in-depth look
MPGH's .NET SDK
eJect - Simple Injector
Basic PE Explorer (BETA)
Hassan (06-28-2012),silentrunner2 (06-28-2012)
You can use the above methods like this:Code:Private Shared Function ExtractSitesFromFile(Filename As String) As List(Of String) Dim TempList As New List(Of String)() Dim Data As String = System.I O.File.ReadAllText(Filename) For Each NextURL As Match In Regex.Matches(Data, "(?<=.*?)www.*") TempList.Add(NextURL.Value) Next Return TempList End Function Private Shared Function ExtractSitesFromText(Source As String) As List(Of String) Dim TempList As New List(Of String)() For Each NextURL As Match In Regex.Matches(Source, "(?<=.*?)www.*") TempList.Add(NextURL.Value) Next Return TempList End Function
Code:For Each Line As String In ExtractSitesFromFile(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\Data.txt") 'MsgBox(Line) -- Display the line. Next
Last edited by Hassan; 06-28-2012 at 10:49 AM.
Last edited by silentrunner2; 06-28-2012 at 03:20 PM.
My ProjectsCOD Ghost Extreme Edition - https://www.mpgh.net/forum/723-call-d...rt-system.html
Account Creator Extreme - https://www.mpgh.net/forum/33-visual-...-websites.html
Don't Ask For Thanks Earn It
You: "Please Give Thanks"
Me: "...................No"
Marked Solved. No more posting !