Function extractMatchingRegex


#include <include/bitextractor.hpp>

void extractMatchingRegex(const wstring &in_file, const wstring &regex, const wstring &out_dir) const


Extracts the regex matching files in the given archive into the choosen directory.

Available only when compiling bit7z using the BIT7Z_REGEX_MATCHING preprocessor define.

in_file - the input archive file.

regex - the regex used for matching the paths of files inside the archive.

out_dir - the output directory where extracted files will be put.


Lines 63-72 in src/bitextractor.cpp. Line 81 in include/bitextractor.hpp.

void BitExtractor::extractMatchingRegex( const wstring& in_file, const wstring& regex, const wstring& out_dir ) const {
    if ( regex.empty() ) {
        throw BitException( "Empty regex filter", E_INVALIDARG );

    const wregex regex_filter( regex, std::regex::ECMAScript | std::regex::optimize );
    extractMatchingFilter( in_file, out_dir, [ &regex_filter ]( const wstring& item_path ) -> bool {
        return std::regex_match( item_path, regex_filter );

Add Discussion as Guest

Log in