Community

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

    Is it possible to...

    Help wanted · · · – – – · · ·
    3
    3
    2121
    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.
    • bill clinton
      bill clinton last edited by

      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
      • gerdb42
        gerdb42 last edited by

        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
        • guy038
          guy038 last edited by

          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
          • First post
            Last post
          Copyright © 2014 NodeBB Forums | Contributors