|
Boost Users : |
From: Edward Diener (eddielee_at_[hidden])
Date: 2003-12-12 13:55:27
In my free Regular Expression Component Library (
http://www.tropicsoft.com/Components/RegularExpression ), which uses regex++
under the covers, you can do in-place modification of a file.
Minuses: source not available, works only on Windows, uses regex++ from
Boost 1.28 rather than latest version, supports BCB3,4,5,6 and VC6,7,7.1
only.
Pluses: Added functionality. I do support it fully. Works solidly, but I
give much credit for that to John Maddock. You don't need to download Boost
regex++ files for it to work, since it is self-contained.
I modified the regex++ source to do the in-place modification of a file
using the same technique that the library uses for searching through files
under Windows, which is the Windows file mapping API.
In the regex_merge, as you have noticed, the output is sent to a separate
string, or an output iterator.
Maybe John Maddock can suggest something for the regex++ implementation
itself which will solve your problem for you.
Scott Meyers wrote:
> I want to use regex to modify a string in place. In particular, I've
> read the contents of a file into a string, now I want to do some
> search/replace functions on the string, then write the modified
> string back out to the original file. I've looked through the regex
> documentation, including the October 2001 DDJ article, but I don't
> see any way to modify a string in place. From what I can tell,
> regex_merge looks like it does the kind of thing I want, except it
> doesn't seem to modify in place. I'd prefer to avoid creating two
> strings of each file's contents, one before regex processsing, one
> after. Is there functionality in regex that will let me modify a
> string in place?
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net