Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    regex, lookbehind error

    Help wanted · · · – – – · · ·
    3
    5
    55
    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
      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.

      PeterJones dinkumoil 2 Replies Last reply Reply Quote 1
      • PeterJones
        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
        • dinkumoil
          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
            Eli Grey @PeterJones last edited by

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

            1 Reply Last reply Reply Quote 0
            • E
              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
              • First post
                Last post
              Copyright © 2014 NodeBB Forums | Contributors