Community
    • Login

    Find and Replace help

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    7 Posts 3 Posters 561 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.
    • Levan DavitadzeL
      Levan Davitadze
      last edited by

      Hello. I want to modify values in multiple files but problem is values differ from one file to another.
      Example:

      test=“6.5” must be replaced by test=“1.0”, but in every file there are different values.

      question: How to find test=“1.0 to 100.0” with step 0.1 and replace them all by test=“1.0”?

      Thank you in advance

      PeterJonesP 1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones @Levan Davitadze
        last edited by PeterJones

        @Levan-Davitadze ,

        It depends on how restrictive you want to be. And how literal your limit of 100.0 was meant to be.

        Do you want test="100.0" to change or not? What about test="100.1"? Do you want to change test="66.0", but not test="66" (so requiring the decimal point, even when it is zero)? There are all sorts of test cases that significantly change the regex.

        With the assumptions that the decimal and tenths digits are required, and that 100.0 is a hard limit and inclusive: FIND = test="1?\d{1,2}\.\d", MODE = Regular Expression. Any other assumptions would require changing the regex.

        –
        addenda: even that assumption shows I forgot to test for edge cases while thinking about edge cases; your original spec says 1.0 to 100.0, but mine allows 0.0 to 100.0 , and I don’t feel like figuring out how to make it more restrictive until we know what your actual edge case needs are.

        Levan DavitadzeL 1 Reply Last reply Reply Quote 2
        • Levan DavitadzeL
          Levan Davitadze @PeterJones
          last edited by Levan Davitadze

          @PeterJones Screenshot 2022-10-19 193952.png

          Thank you for your suggestion. I don’t think value goes to 100.0. mostly it will be under 9.9. Don’t know if I got you right, but seems it isn’t working. Anyways thanks for help.

          *edit.

          Thank you it is working flawlesly.

          PeterJonesP 1 Reply Last reply Reply Quote 0
          • PeterJonesP
            PeterJones @Levan Davitadze
            last edited by

            @Levan-Davitadze said in Find and Replace help:

            Don’t know if I got you right, but seems it isn’t working

            Your screenshot shows “Normal” mode, you need “Regular expression” mode.

            *edit. Thank you it is working flawlesly.

            I included this note even after I saw the edit, so that future readers will know what was wrong.

            Levan DavitadzeL 1 Reply Last reply Reply Quote 4
            • Levan DavitadzeL
              Levan Davitadze @PeterJones
              last edited by Levan Davitadze

              @PeterJones Hello friend.

              I need another help if you have time please.

              Can you suggest how to reduce and replace with reduced value existing one, instead of writing exact number? f.e. "BodyFrictionAsphalt=“found value/2” or percent of found value, f.e. …=found value 34%

              Thank you very much in advance.

              Alan KilbornA 1 Reply Last reply Reply Quote 0
              • Alan KilbornA
                Alan Kilborn @Levan Davitadze
                last edited by

                @Levan-Davitadze said in Find and Replace help:

                Can you suggest how to reduce and replace with reduced value existing one, instead of writing exact number? f.e. "BodyFrictionAsphalt=“found value/2” or percent of found value, f.e. …=found value 34%

                You are talking about doing a mathematical replacement.
                There is no native support in Notepad++ for that.
                If you want to do it with Notepad++, you have to do scripting.
                More information is HERE.

                Levan DavitadzeL 1 Reply Last reply Reply Quote 3
                • Levan DavitadzeL
                  Levan Davitadze @Alan Kilborn
                  last edited by

                  @Alan-Kilborn 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