Community
    • Login

    need some help with find and replace

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    4 Posts 2 Posters 3.3k 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.
    • Clearinghouse ForsaleC
      Clearinghouse Forsale
      last edited by

      i need some help, i want to find and replace the age value and make it 7200.000… but not change any of the other text.

      example
      BEGIN “[i 0]” Id.i 0 Id.u 14649 Type Tree SubType 2 Pos.x 133.0000 Pos.y 59.00000 Age 1529.771 END
      BEGIN “[i 1]” Id.i 1 Id.u 20202 Type Garbage SubType 2 Pos.x 198.0007 Pos.y 113.3049 Lifetime 1365.457 END
      BEGIN “[i 2]” Id.i 2 Id.u 9337 Type Tree SubType 2 Pos.x 4.999023 Pos.y 62.23138 Age 400.000 END
      BEGIN “[i 3]” Id.i 3 Id.u 9338 Type Tre7 SubType 2 Pos.x 9.386169 Pos.y 20.61072 Age 200.000 END
      now as you see, i have alot of lines that state begin…type tree…age ##### end
      i want to chage the ##### value to 7200.000 without changing anything else…how do i do that??

      1 Reply Last reply Reply Quote 0
      • Clearinghouse ForsaleC
        Clearinghouse Forsale
        last edited by

        can it even be done?
        only changing a part of certain lines without altering the other parts of those lines???

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

          Hi, @clearinghouse-forsale,

          Quite easy to achieve, with regular expressions :-)

          • 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à !

          Notes :

          • First, it searches for the word Age, surrounded with 2 spaces ( Age )

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

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

          • But ONLY IF that list is followed with a space and the word END ( (?= END) ). The syntax (?= END) is called a look-ahead, that must be verified, but that it’s NOT part of the final text matched. So, the strings, matched, are only the strings like 1365.457, 400.000, or 200.000, located after the word Age

          • In the Replace zone, these different matched strings are, simply, replaced with the string 7200.000

          Best Regards,

          guy038

          1 Reply Last reply Reply Quote 0
          • Clearinghouse ForsaleC
            Clearinghouse Forsale
            last edited by

            thank you

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