Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

removing strings from files

hi, i was wondering those anybody know of, or have a program that is capable of deleting a full line/string, due to a string having a specific substring.
examlpe,
i have a dataset

item1
item2.xxx
item3

item1
item4.xxx

and want

item1
item3

item1

thanks in advance,
damien


Comments

  • GiantGiant Member Posts: 225
    Hi Damien.
    That would not be that hard to do. The Pseudo Code would be as follows.

    [code]
    Open the file for reading.
    while( not end of file )
    read in line
    if(line does not contain specific string)
    place line in struct and place on the end of a list
    end if
    end while
    [/code]

    You now have a linked list of structures holding the strings that you want too keep.

    close the file and open it again to overwrite the contents.

    Starting at the start of the list visit each node, and write the info to the file.

    I am only guessing here, and it might all be a load of crap, but it should work

    Giant

Sign In or Register to comment.