Search and Replace in .txt file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SR90
    New Member
    • May 2007
    • 2

    Search and Replace in .txt file

    I need help. Been trying to do this all morning.

    I Basically need to open a text file. Find a string of text and replace it with another string of text. Then close the file.

    So say, I open the file, and i need to find every string in the file with "Hello" and replace it with "Goodbye". Then close and save the file.

    How do i do this??

    Thanks.
  • AdrianH
    Recognized Expert Top Contributor
    • Feb 2007
    • 1251

    #2
    Originally posted by SR90
    I need help. Been trying to do this all morning.

    I Basically need to open a text file. Find a string of text and replace it with another string of text. Then close the file.

    So say, I open the file, and i need to find every string in the file with "Hello" and replace it with "Goodbye". Then close and save the file.

    How do i do this??

    Thanks.
    Well, off hand, I would say, open the file, open another file, read in the file, find a string of text you are looking for and replace it with some other text, write out the file to the other file. Keep doing that till you get to the end of the file and then close the file.

    How are you doing it?


    Adrian

    Comment

    Working...