Community

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

    Find and Replace help

    Help wanted · · · – – – · · ·
    3
    7
    125
    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 Davitadze
      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

      PeterJones 1 Reply Last reply Reply Quote 0
      • PeterJones
        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 Davitadze 1 Reply Last reply Reply Quote 2
        • Levan Davitadze
          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.

          PeterJones 1 Reply Last reply Reply Quote 0
          • PeterJones
            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 Davitadze 1 Reply Last reply Reply Quote 4
            • Levan Davitadze
              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 Kilborn 1 Reply Last reply Reply Quote 0
              • Alan Kilborn
                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 Davitadze 1 Reply Last reply Reply Quote 3
                • Levan Davitadze
                  Levan Davitadze @Alan Kilborn last edited by

                  @Alan-Kilborn Thank you.

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post
                  Copyright © 2014 NodeBB Forums | Contributors