zufuliu / notepad2

Notepad2-zufuliu is a light-weight Scintilla based text editor for Windows with syntax highlighting, code folding, auto-completion and API list for many programming languages and documents, bundled with file browser plugin metapath-zufuliu.
Other
2.3k stars 168 forks source link

Multiline regular expressions #53

Open zufuliu opened 5 years ago

zufuliu commented 5 years ago

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

zufuliu commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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.

whileloopa commented 5 years ago

I look forward to the release of a test build.

zufuliu commented 5 years ago

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

zufuliu commented 4 years ago

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

oicu commented 3 years ago

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

Mapaler commented 2 years ago

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