notepad4 icon indicating copy to clipboard operation
notepad4 copied to clipboard

Multiline regular expressions

Open zufuliu opened this issue 7 years ago • 8 comments

See https://github.com/XhmikosR/notepad2-mod/issues/148.

zufuliu avatar Sep 01 '18 23:09 zufuliu

Multiline regular expressions is not build by default, REGEX_MULTILINE macro is is undefined on build.

C++ regular expressions also not build by default, from https://en.cppreference.com/w/cpp/regex/syntax_option_type, C++ regex support ECMAScript, POSIX, extended POSIX, awk, grep and egrep style regex, which is attractive.

zufuliu avatar Sep 01 '18 23:09 zufuliu

VC runtime support multiline regexp (with \n line endings):

#include <iostream>
#include <regex>

int main(void) {
    std::string doc(
        "begin xxx\n"
            "stmt\n"
        "end xxx\n");

    std::regex re(R"(^begin\s+\w+[\s\S]+end\s+\w+$)", std::regex::ECMAScript);
    std::smatch m;
    if (std::regex_search(doc, m, re)) {
        for (auto x : m) {
            std::cout << "[" << x << "]" << std::endl;
        }
    } else {
        std::cout << "no match" << std::endl;
    }

    return 0;
}

zufuliu avatar Oct 17 '18 01:10 zufuliu

Need build Scintilla with C++11 regex and REGEX_MULTILINE, and replace SCFIND_POSIX with SCFIND_CXX11REGEX (add a new option) in Find and Replace dialog.

zufuliu avatar Oct 17 '18 01:10 zufuliu

I look forward to the release of a test build.

whileloopa avatar Oct 27 '18 12:10 whileloopa

The multiline regex doen't support \r\n (CR+LF) line endings, which may not useful.

zufuliu avatar Oct 27 '18 12:10 zufuliu

[For bookmark purpose] "A comparison of regex engines" on https://rust-leipzig.github.io/regex/2017/03/28/comparison-of-regex-engines/

zufuliu avatar May 08 '20 23:05 zufuliu

看到 Notepad3 已经实现了多行正则匹配,期待 Notepad2 加上这个~

oicu avatar Dec 17 '20 13:12 oicu

不能直接换正则表达式引擎吗,VScode的就很好用,Notepad2的总是怪怪的。

Mapaler avatar Jan 19 '22 12:01 Mapaler