• Login
Community
  • Login

Is it possible to...

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
3 Posts 3 Posters 2.4k 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.
  • B
    bill clinton
    last edited by Apr 29, 2016, 2:49 AM

    Take these two lines for example

    Contents Log Quantity 6 LastAccess 54200 END
    Contents Log Quantity 2 END

    using the search formula: Log Quantity\K.+(?= END)
    and the replace being, say 1000…

    can I NOT include the first line that says “LastAccess” from being replaced?

    so that it ends up being

    Contents Log Quantity 6 LastAccess 54200 END
    Contents Log Quantity 1000 END

    because that formula selects "6 LastAccess 54200 " as well as what I want to change…

    there must be some exclusion formula I can add in, right?

    1 Reply Last reply Reply Quote 0
    • G
      gerdb42
      last edited by Apr 29, 2016, 7:32 AM

      How about this one: (?<=Log Quantity )\d+(?! LastAccess)(?=.+END)

      See boost regex page for more information about RegEx syntax.

      1 Reply Last reply Reply Quote 0
      • G
        guy038
        last edited by Apr 29, 2016, 7:59 PM

        Hello, bill clinton and Gerdb42,

        If I refer to the original text, posted by bill clinton, below :

        https://notepad-plus-plus.org/community/topic/11716/help-with-formula-please/1

        it seems, that there are two spaces between the words Log and Quantity, as well as between the Qty number and the LastAccess string.

        So, rather that typing two spaces, we may use a SPACE, followed by the + quantifier ( identical to the syntax {1,}) )

        That comes to the regex :

        (?-i)Log +Quantity +\K\d+(?! +LastAccess)

        Notes :

        • You’ll notice that I did NOT use the following look-behind (?<=Log +Quantity +). Indeed it’s an invalid regular expression, because this regex may represent strings of different length ( due to the + quantifier )

        • It is important to notice that this restriction does NOT apply to look-aheads, as ( (?! +LastAccess) )

        • So, I replaced the look-behind with the \K construction. Thus, once, the regex has matched the regex Log +Quantity +,
          this string is forgotten and the regex engine match is reset to a zero length string !

        • Finally, the (?-i) modifier, at the beginning, forces the regex engine to perform a NON insensitive case search

        Best Regards,

        guy038

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