Results 1 to 13 of 13
  1. #1
    silentrunner2's Avatar
    Join Date
    Jun 2008
    Gender
    male
    Posts
    629
    Reputation
    110
    Thanks
    2,870
    My Mood
    Busy

    Remove Number Sequence

    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 Projects


    Don't Ask For Thanks Earn It
    You: "Please Give Thanks"
    Me: "...................No"

  2. #2
    Pingo's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Posts
    687
    Reputation
    24
    Thanks
    865
    My Mood
    Blah
    do they all end in .com

  3. #3
    silentrunner2's Avatar
    Join Date
    Jun 2008
    Gender
    male
    Posts
    629
    Reputation
    110
    Thanks
    2,870
    My Mood
    Busy
    Quote Originally Posted by Pingo View Post
    do they all end in .com
    some of them yes but alot are different, there must be a way to do it I just want to get rid of the numbers and fallstop after the number so im left with just the urls/links :/
    My Projects


    Don't Ask For Thanks Earn It
    You: "Please Give Thanks"
    Me: "...................No"

  4. #4
    Blubb1337's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Germany
    Posts
    5,915
    Reputation
    161
    Thanks
    3,108
    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.



  5. #5
    Pingo's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Posts
    687
    Reputation
    24
    Thanks
    865
    My Mood
    Blah
    Quote Originally Posted by silentrunner2 View Post
    some of them yes but alot are different, there must be a way to do it I just want to get rid of the numbers and fallstop after the number so im left with just the urls/links :/
    I'll put together something for ya.

  6. #6
    Jorndel's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    Norway
    Posts
    8,676
    Reputation
    905
    Thanks
    19,113
    My Mood
    Angelic
    Enum list and check?

    Or, I got this wrong :S

     
    Contributor 01.27.2012 - N/A
    Donator 07-17-2012 - Current
    Editor/Manager 12-16-12 - N/A
    Minion 01-10-2013 - 07.17.13
    Former Staff 09-20-2012 - 01-10-2013 / 07-17-2013 - Current
    Cocksucker 20-04-2013 - N/A

  7. #7
    Blubb1337's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Germany
    Posts
    5,915
    Reputation
    161
    Thanks
    3,108
    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 Function
    Code:
    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.



  8. #8
    Pingo's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Posts
    687
    Reputation
    24
    Thanks
    865
    My Mood
    Blah
    @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

  9. #9
    Jorndel's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    Norway
    Posts
    8,676
    Reputation
    905
    Thanks
    19,113
    My Mood
    Angelic
    So, no Number Enum Check then?
    (Don't know how It would be make in VB.Net)

     
    Contributor 01.27.2012 - N/A
    Donator 07-17-2012 - Current
    Editor/Manager 12-16-12 - N/A
    Minion 01-10-2013 - 07.17.13
    Former Staff 09-20-2012 - 01-10-2013 / 07-17-2013 - Current
    Cocksucker 20-04-2013 - N/A

  10. #10
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    Quote Originally Posted by Jorndel View Post
    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:

    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
    Call it like so:
    Code:
    FormatFile("B:\fuckedformatting.txt", "B:\niceformatting.txt")
    Or if you want to be a shitcunt and not worry about memory:

    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)))
    Or use the above code to manipulate the text in memory. Either way.

    Quote Originally Posted by Jeremy S. Anderson
    There are only two things to come out of Berkley, Unix and LSD,
    and I don’t think this is a coincidence
    You can win the rat race,
    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)

  11. The Following 2 Users Say Thank You to Jason For This Useful Post:

    Hassan (06-28-2012),silentrunner2 (06-28-2012)

  12. #11
    Hassan's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    System.Threading.Tasks
    Posts
    4,764
    Reputation
    495
    Thanks
    2,133
    My Mood
    Dead
    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
    You can use the above methods like this:

    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.

  13. #12
    silentrunner2's Avatar
    Join Date
    Jun 2008
    Gender
    male
    Posts
    629
    Reputation
    110
    Thanks
    2,870
    My Mood
    Busy
    Quote Originally Posted by Jason View Post


    Just shut your cunt and let the real men handle it.

    Simple way:

    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
    Call it like so:
    Code:
    FormatFile("B:\fuckedformatting.txt", "B:\niceformatting.txt")
    Or if you want to be a shitcunt and not worry about memory:

    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)))
    Or use the above code to manipulate the text in memory. Either way.
    worked like a charm, thanks a bunch
    Last edited by silentrunner2; 06-28-2012 at 03:20 PM.
    My Projects


    Don't Ask For Thanks Earn It
    You: "Please Give Thanks"
    Me: "...................No"

  14. #13
    Hassan's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    System.Threading.Tasks
    Posts
    4,764
    Reputation
    495
    Thanks
    2,133
    My Mood
    Dead
    Marked Solved. No more posting !

Similar Threads

  1. should we REMOVE THE EDIT BUTTON?
    By ace76543 in forum Spammers Corner
    Replies: 12
    Last Post: 02-04-2021, 02:01 PM
  2. Iverson's Comic Number 3
    By iverson954360 in forum General
    Replies: 11
    Last Post: 07-19-2009, 03:02 AM
  3. Iverson's Comic Number 2
    By iverson954360 in forum General
    Replies: 21
    Last Post: 07-18-2009, 07:38 PM
  4. removing softnyx nprotect!!!
    By terence in forum General Game Hacking
    Replies: 12
    Last Post: 01-08-2006, 12:57 AM
  5. i need short icq number pls and hack to wr..
    By BoneXDBreaker in forum WarRock - International Hacks
    Replies: 1
    Last Post: 12-26-2005, 05:08 PM