When you see a word you don''t understand, it''s often helpful to google for it:
quote: Sed (streams editor) isn''t really a true text editor or text processor. Instead, it is used to filter text, i.e., it takes text input and performs some operation (or set of operations) on it and outputs the modified text. Sed is typically used for extracting part of a file using pattern matching or substituting multiple occurances of a string within a file.
Do you use Visual C++? If you do, then, in the Find/Replace dialog box, you can check "Regular expressions". This is a really powerful feature which lets you do really neat text replacements. I dunno if you''re familiar with regular expressions, if not then here''s some info..
Regular expressions let you search for complex patterns. For example:
To find a capital letter, you''d say: [A-Z]
To find a string of lowercase letters you''d say: [a-z]+
To find an identifier (some word which could potentially be used as a variable in some programming language): \:i
To find a character which isn''t #: [^#]
To turn a bunch of functions which look like: void SetAlpha(int alpha)
into:
void Graphics::SetAlpha(int alpha)
You could say:
Find: void \(\:i\)(\(\:i\))
Replace with: void Graphics::\1(\2)
Once you get used to it, it''s pretty easy to spit out huge expressions like the ones above, so when you have some really repetitive text editing task, it can be quite handy..
Perl and Python are currently on my list. I am trying to distinguish witch one to buy a book on. Any suggestions, with one is, um, better (please don’t start a war) ?
Python: should be plenty of introductory info on their site. However, it''s not the best at stream processing; that''s not what it was meant for. PERL, on the other hand, was originally designed for data processing and modification, and is somewhat easier to do this stuff in. Good info is available everywhere, but the O''Reilly books on Perl are by far the best.
I was going to suggest awk, but it''s really more appropriate for files which are line-oriented -- C++ is not. You could separate by semicolons, but even that is very chancy (think about for statements). Also, awk is more useful for situations where the output does not closely resemble the input.
Still, awk is a great language to know; it''s perfect for implementing many one-off processing scripts.