Using regex on a file
Hello all, I would like to programmatically search a (large) binary file for a particular text string and get a boolean result back - either the string appeared or it did not. I imagine whatever I end up implementing will be platform-independent, but I'll state anyway that I am using Visual C++. My first thought was to use regex_search and pass it two stream iterators, one pointing to the beginning of the file and one representing the end of the file. Alas, this won't work since regex_search requires bidirectional iterators, which stream iterators are not. I would appreciate any suggestions as to how I can most efficiently and elegantly achieve my goal. Thank you! Dave
Dave wrote:
Hello all,
I would like to programmatically search a (large) binary file for a particular text string and get a boolean result back - either the string appeared or it did not.
I imagine whatever I end up implementing will be platform-independent, but I'll state anyway that I am using Visual C++. My first thought was to use regex_search and pass it two stream iterators, one pointing to the beginning of the file and one representing the end of the file. Alas, this won't work since regex_search requires bidirectional iterators, which stream iterators are not. I would appreciate any suggestions as to how I can most efficiently and elegantly achieve my goal. Thank you!
A memory mapped file would be my first choice, but if the text is too long even for that then see http://www.boost.org/libs/regex/doc/partial_matches.html HTH, John.
participants (2)
-
Dave
-
John Maddock