Deleting/Gathering Text from File

Hi, I have a file in wordpad that I need to delete a few strips. Its about 500 pages long so I cannot do it manually (it takes forever). I kind of understand how do approach this with c++. Well here's an example:

? = random text

?????????????????????????????<LastName>Doe</LastName><FirstName>John</FirstName><SSN>123456789</SSN><SSNNA>0</SSNNA>?????????????????????????????

I want to keep the ??? and get rid of the text. Its repeted over and over throughout the body. Also the numbers change and the names change of course throughout.

Example:

while( getline(in,line) )
{
if(line != "I want to delete this line")
out << line << "\n";
}
in.close();
out.close();

(taken from: http://www.daniweb.com/code/post969008.html#)

Now for the if(line) part can I write if(line != "<LastName>" to "</SSNNA>")

to get rid of the whole chunk? or else how do I do that? Thank you.

You could use an editor with regular expressions.
Replace: (.*)\<LastName\>.*\<\/SSNNA\>(.*)
With: \1\2
Sorry I dont understand :(
You could use a text editor that supports regular expressions, such as Notepad++.
Idk how.
You don't know how to use a text editor?
no =(
do you know how to use a "keyboard"?
I... Uh... What? How is that possible? What do you write your code with, then?
i use my keyboard
Since you're being such a smartass, I guess you don't need any help. Good luck.
What im not being the smart ass you were? You aren't very helpful anyways.
If your editor supports regular expressions, you can use its search and replace function
to find the text and replace it with nothing.

Helios suggested what you should enter as the search text.
The "replace with" text should be \1\2, which have special
meaning in regular expressions.

If you aren't following, then I'm guessing without looking that Wikipedia
will have a nice article on REs that will be a good primer for you.

Anyway, REs are probably what you want, whether you go with the editor-based
solution or a C++-based solution.
Find What: (.*)\<LastName\>.*\<\/SSNNA\>(.*)

"Error: Search string not found!"

What do u mean
Make sure you have enabled regular expressions...
I did
please help me : (
You can do it from the command line.
grep -v "I want to delete this line" inputfile > outputfile
I can't get (.*)\<LastName\>.*\<\/SSNNA\>(.*) to work.
Topic archived. No new replies allowed.