Program search + replacement in .doc

If I am provided with a .doc file with special tags in it, for example, [first_name], how can I replace all occurrences of it with something like "Clark"? A simple binary replacement only works if the replacement string is the same length.

Haskell, C and C ++ answers would be better, but any compiled language could do. I would also prefer to do this without an external library, as it needs to be deployed on Windows and Linux, and cross-platform dependency handling is a bitch.

Summarizing...

.doc -> magic program -> .doc with strings replaced
+3
source share
4 answers

Word COM ( "Word.Application" ) Windows, , , . Windows .

, , - OpenOffice.org ODF, (ODF - , , zipped XML), , , .doc. OpenOffice.org Word (, ), ( OpenOffice.org, ).

, .docx, , .

+4

Word.

, , . ; Word .

+2

, , .Net(VB #) Word.Application, MS Word .

+1

C/++/Haskell ? Haskell, , C . (Perl, Python ..) , .

With that said, as other posters noted, you still have to deal with eccentricities in the .doc format.

0
source

Source: https://habr.com/ru/post/1759202/


All Articles