Community
    • Login

    help on a formula, please?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    4 Posts 3 Posters 3.4k Views 2 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.
    • harry reidH Offline
      harry reid
      last edited by

      Hi, I need some help please.

      I asked a question some time back on this site, and now i need another answer.

      take this setup for example:

      BEGIN “[i 0]” Type Wife Age 7200.000 SkinColour 0x000000ff END
      BEGIN “[i 1]” Type Son Age 7200.000 SkinColour 0x000000ff END
      BEGIN “[i 2]” Type Tree SubType 5 Pos.x 10.49121 Pos.y 111.7811 Age 7200.000 END
      BEGIN “[i 3]” Type Tree SubType 2 Pos.x 13.77533 Pos.y 34.22266 Age 7200.000 END

      someone already told me how to modify the “Age” of a “Tree” earlier…
      ? Open the Replace dialog ( CTRL + H )
      ? Select the Regular expression search mode
      ? Preferably, check the Match case option
      ? Check the Wrap around option, if necessary
      ? In the Find What zone, type Age \K.+(?= END)
      Remark : There a space, before the word Age AND after it, as well as before the word END !
      ? In the Replace with zone, type, simply, the string 7200.000
      ? Click on the Replace All button
      Et voilà !

      but HERE IS THE QUESTION: how do i alter the steps to make sure it only includes the “Tree” Age??

      1 Reply Last reply Reply Quote 0
      • harry reidH Offline
        harry reid
        last edited by

        no one knows how to search and replace the age values in the last two “Tree” lines only??

        1 Reply Last reply Reply Quote 0
        • Claudia FrankC Offline
          Claudia Frank
          last edited by

          Is there a reason why having the same topic open twice??
          This isn’t very kind, isn’t it.

          Cheers
          Claudia

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

            Hello Harry,

            I’m the one, who posted this reply to Clearinghouse Forsale, three months ago, about ! Refer to the link below :

            https://notepad-plus-plus.org/community/topic/10848/need-some-help-with-find-and-replace/3

            And indeed, reading again this old post, I just realize that I didn’t pay enough attention to the line :

            now as you see, i have alot of lines that state begin…type tree…age ##### end

            So, the replacement should occur, ONLY IF the lines contain the word Tree, before the word Age !

            In that case, just change the search regex as :

             Tree .* Age \K.+(?= END$)
            

            REMARKS :

            • There a space, BEFORE and AFTER the words Tree and Age, and a space BEFORE the last word END !

            • I also added the $ symbol, to be sure that we search for the word END, at the very end of each line

            NOTES :

            • This time, the search regex is looking, FIRST, for any text, in a same line, between a first occurrence of the word Tree and a last occurrence of the word Age ( Tree .* Age )

            • Due to the \K form, this previous match is, then, forgotten by the regex engine

            • Next, it tries to match a non empty list of characters (.+)

            • But, ONLY IF that list is followed with a space and the word END, which ends the current line ( (?= END$) ). So it selects the exact number, only, between the word Age and the keyword END !

            Best Regards,

            guy038

            1 Reply Last reply Reply Quote 0

            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