• Login
Community
  • Login

Find and Replace help

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
7 Posts 3 Posters 571 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.
  • L
    Levan Davitadze
    last edited by Oct 19, 2022, 3:11 PM

    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

    P 1 Reply Last reply Oct 19, 2022, 3:17 PM Reply Quote 0
    • P
      PeterJones @Levan Davitadze
      last edited by PeterJones Oct 19, 2022, 3:19 PM Oct 19, 2022, 3:17 PM

      @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.

      L 1 Reply Last reply Oct 19, 2022, 3:45 PM Reply Quote 2
      • L
        Levan Davitadze @PeterJones
        last edited by Levan Davitadze Oct 19, 2022, 3:46 PM Oct 19, 2022, 3:45 PM

        @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.

        P 1 Reply Last reply Oct 19, 2022, 3:53 PM Reply Quote 0
        • P
          PeterJones @Levan Davitadze
          last edited by Oct 19, 2022, 3:53 PM

          @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.

          L 1 Reply Last reply Dec 9, 2022, 8:37 AM Reply Quote 4
          • L
            Levan Davitadze @PeterJones
            last edited by Levan Davitadze Dec 9, 2022, 8:39 AM Dec 9, 2022, 8:37 AM

            @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.

            A 1 Reply Last reply Dec 9, 2022, 12:21 PM Reply Quote 0
            • A
              Alan Kilborn @Levan Davitadze
              last edited by Dec 9, 2022, 12:21 PM

              @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.

              L 1 Reply Last reply Dec 9, 2022, 5:16 PM Reply Quote 3
              • L
                Levan Davitadze @Alan Kilborn
                last edited by Dec 9, 2022, 5:16 PM

                @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