954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Edit and replace strings in a text file

Hi,
I am trying to replace a few text strings in a text file (test.txt), and then makeing some spaces, for it to be easier to read

Anyone have an example I can use, because I am new to C++

I just want to replace "word1" with red "word2", and then if the outputfile couldt be in html, then it should be posible to convert the black"word1" with red"word2"

I have tried to use an SED editor, and it works ok. But I would like to have the option to have different colour in the output file.
There for I hope that someone would make me a sample file. I think it is quite easy for people that know a little about c++

Regards
Brian

bbhe
Newbie Poster
2 posts since Sep 2008
Reputation Points: 10
Solved Threads: 0
 

Hi, I am trying to replace a few text strings in a text file (test.txt), and then makeing some spaces, for it to be easier to read

Anyone have an example I can use, because I am new to C++

I just want to replace "word1" with red "word2", and then if the outputfile couldt be in html, then it should be posible to convert the black"word1" with red"word2"

I have tried to use an SED editor, and it works ok. But I would like to have the option to have different colour in the output file. There for I hope that someone would make me a sample file. I think it is quite easy for people that know a little about c++

Regards Brian


It may well be easy for people who know C++, but one, we have no idea what your input file looks like, and two, we don't know what you want the output file to look like given a certain input file. I can guess what they may look like, but your explanation is not sufficient. Three, no one is going to write the whole program for you. Provide a short input file and the output file that corresponds to it and post your attempt.

VernonDozier
Posting Expert
5,527 posts since Jan 2008
Reputation Points: 2,633
Solved Threads: 711
 

>>I have tried to use an SED editor, and it works ok. But I would like to have the option to have different colour in the output file

There is no such thing as color in a file. To color, or not to color is all up to the editor that is being used. In HTML you have [color=???] tags. There isn't anything like that in plain text files.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

I think you are trying to create an html file, which does support colored text. To do this, you will need a very basic knowledge of both the fstream library and html coding. If you do not have this knowledge then it will be very difficult to help you.

skatamatic
Posting Shark
959 posts since Nov 2007
Reputation Points: 403
Solved Threads: 129
 
I think you are trying to create an html file, which does support colored text. To do this, you will need a very basic knowledge of both the fstream library and html coding. If you do not have this knowledge then it will be very difficult to help you.


You are right. The output file should be a html.
I will try to read something about the fstream library.
Thanks for the reply

bbhe
Newbie Poster
2 posts since Sep 2008
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You