Community
    • Login

    regex, lookbehind error

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    5 Posts 3 Posters 1.5k Views 3 Watching
    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.
    • E Offline
      Eli Grey
      last edited by Eli Grey

      I tried (?<=\s+) for searching 2 or more empty (allowing tab or spacebar inserted) line but this gives me an error.
      The error message is ‘Find : invalid regular expression’.

      I tested lookbehind and \s+ separately and both work fine. I want to know what is wrong when those two expressions are combined together.

      Actually, even (?<=\s) work fine too, but when I add + or * to the right side of \s to allow multiple whitespaces, the error occurs. Someone help me please.

      PeterJonesP dinkumoilD 2 Replies Last reply Reply Quote 1
      • PeterJonesP Online
        PeterJones @Eli Grey
        last edited by PeterJones

        @Eli-Grey ,

        Lookbehinds must be of a fixed length. \s+ is not fixed width.

        https://npp-user-manual.org/docs/searching/#assertions

        edit: the manual also suggests a workaround using \K, so instead of (?<=\s+)REALTEXT, use \s+\KREALTEXT

        E 1 Reply Last reply Reply Quote 5
        • dinkumoilD Offline
          dinkumoil @Eli Grey
          last edited by

          @Eli-Grey

          Additionally to what @PeterJones said, I want to mention that this is a restriction of the boost regular expression engine that Notepad++ uses under the hood. There are a few regular expression engines that don’t have this restriction (see section Important Notes About Lookbehind >> at this site <<), but in Notepad++ we have to live with it.

          E 1 Reply Last reply Reply Quote 5
          • E Offline
            Eli Grey @PeterJones
            last edited by

            @PeterJones Thank you so much, I understood what I need.

            1 Reply Last reply Reply Quote 0
            • E Offline
              Eli Grey @dinkumoil
              last edited by

              @dinkumoil Thank you, actually I’m studying regex with 'Mastering Regex by Jeffrey Friedl and maybe I didn’t consider the differences on those engines.

              1 Reply Last reply Reply Quote 2

              Hello! It looks like you're interested in this conversation, but you don't have an account yet.

              Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

              With your input, this post could be even better 💗

              Register Login
              • First post
                Last post
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors