Edit and replace strings in a text file

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2008
Posts: 2
Reputation: bbhe is an unknown quantity at this point 
Solved Threads: 0
bbhe bbhe is offline Offline
Newbie Poster

Edit and replace strings in a text file

 
0
  #1
Sep 21st, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 3,828
Reputation: VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute 
Solved Threads: 501
Featured Poster
VernonDozier VernonDozier is offline Offline
Senior Poster

Re: Edit and replace strings in a text file

 
0
  #2
Sep 21st, 2008
Originally Posted by bbhe View Post
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.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,454
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1476
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: Edit and replace strings in a text file

 
0
  #3
Sep 21st, 2008
>>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.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 390
Reputation: skatamatic will become famous soon enough skatamatic will become famous soon enough 
Solved Threads: 39
skatamatic skatamatic is offline Offline
Posting Whiz

Re: Edit and replace strings in a text file

 
0
  #4
Sep 22nd, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 2
Reputation: bbhe is an unknown quantity at this point 
Solved Threads: 0
bbhe bbhe is offline Offline
Newbie Poster

Re: Edit and replace strings in a text file

 
0
  #5
Sep 23rd, 2008
Originally Posted by skatamatic View Post
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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC