Community
    • Login

    Building a multi-line RegEx

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    2 Posts 2 Posters 1.7k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • glennfromiowaG
      glennfromiowa
      last edited by

      Rather than open an old thread, I thought I’d start a new one. I was using the method discussed by @guy038 to build a multi-line RegEx, when the Notepad++ Find box gave me a message that I had an invalid regular expression. I narrowed it down to using the any line ending character sequence \R character escape along with the Ignore unescaped whitespace (?x) flag.

      Interestingly enough, using a RegEx of (?x)\R in the Find dialog box will give you an Invalid regular expression error, while using a RegEx of \R will not. Could this be a bug in the current Boost C++ Regex library? Although I wanted to share that combination to avoid with the community, I also wonder if anyone else has come across any other characters or parts of a RegEx that are invalid when used in conjunction with the (?x) flag?

      1 Reply Last reply Reply Quote 1
      • guy038G
        guy038
        last edited by guy038

        Hello, @glennfromiowa and All,

        I’m totally sorry for my very late reply ! I’ve just missed that post :-((

        You’re perfectly right on that matter. Indeed, it’s a Boost regex library bug ! Refer to these two links for explanations :

        https://svn.boost.org/trac10/ticket/12960

        https://github.com/boostorg/regex/commit/a32e0cc9d39f8c0886fe5576022c7bf0c9efc265

        And, probably, this issue was fixed since the regex library 5.1.3, of the Boost C++ libraries v1.66.0 ( or v1.67.0 )


        Of course, we’ll have to live with that tiny bug… as N++ is using the regex component of Boost library v1.55.0 !

        However, we just have to be aware of that fact and, IF using the (?x) modifier, simply replace any \R syntax with the sequence \r\n ( or possibly \n ), in the search regex !

        Cheers,

        guy038

        P.S. :

        After some tests, I don’t think that other regex syntaxes become bugged, when using the free-spacing mode ( (?x) ) !

        1 Reply Last reply Reply Quote 4
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors