replace in large string

std/boost regex_replace returns modified string by value. In my case I have to search/replace by regex in a file. I have thousands of files to process and many of them are over 1MB in size. The string to be searched and replaced is rare (eg only 5-10% of files will have it). So, with the available interface is that possible to run regex replace and if the searched string isn't found then avoid creating a copy of 1MB buffer? I just don't seem to figure out, is that regex interface in c++ that failed that the only way is to first search for a string in my buffer and only if it's found then use regex_replace (effectively search for the second time)? Or can I reuse results from regex_match or regex_search and pass them to regex_replace?

链接地址: http://www.djcxy.com/p/31548.html

上一篇: 为什么C ++比带boost的python快得多?

下一篇: 以大字符串替换