Community
    • Login

    The number of digits after the point in the code that is in Notoped++

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    8 Posts 3 Posters 2.7k 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.
    • rita252525R
      rita252525
      last edited by

      Hello.
      I need to reduce the number of digits after the point in the code that is in Notoped++ . For example: in the code 3.6787687 need to be 3.67. Thanks.

      1 Reply Last reply Reply Quote 0
      • Terry RT
        Terry R
        last edited by

        I might be looking at this the wrong way but if ALL numbers are to be altered then try this:
        Find:(\d+.\d{1,2})\d*
        Replace:\1

        So it doesn’t care how many digits to the left of the “.” as long as there is at least 1 (denoted by the “+”). Then it must have a “.” followed by as many digits as there are, however the first 2 are kept in the ‘saved string’ “\1” which is the replacement.
        If you need to change the number of digits kept after the “.” change the numbers in the {}, i.e. {1,3}.
        A quick test with a number like 1.2 still left it as 1.2, whereas a longer one was truncated back to 2 significant digits. This does NOT round, only truncates which your examples suggests what you want to achieve.

        Terry

        1 Reply Last reply Reply Quote 1
        • Terry RT
          Terry R
          last edited by

          My previous post had an error. I will blame fat fingers.
          The Find string should be “(\d+.\d{1,2})\d*”. Grab the characters inside the "'s (don’t include the "). The error was with the “.”. As it has special significance in regex’s it needs the “” before it to say we actual want the “.”, not the character group it represents.

          Terry

          1 Reply Last reply Reply Quote 0
          • Jim DaileyJ
            Jim Dailey
            last edited by

            @Terry-R
            I can’t see any difference in your 2 expressions. Did you mean this?

            (\d+\.\d{1,2})\d*
            
            1 Reply Last reply Reply Quote 0
            • rita252525R
              rita252525
              last edited by

              What to put In the line “to replace” ?

              1 Reply Last reply Reply Quote 0
              • Jim DaileyJ
                Jim Dailey
                last edited by

                @rita252525

                \1
                
                1 Reply Last reply Reply Quote 0
                • Terry RT
                  Terry R
                  last edited by

                  OK, so it’s not fat fingers it’s poor eyesight. i could swear that the “” was missing, now it’s back again. This time I’ll blame my monitor for rubbing out that character!

                  Terry

                  1 Reply Last reply Reply Quote 0
                  • rita252525R
                    rita252525
                    last edited by

                    Thank you. It works.

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