• Login
Community
  • Login

only replace exact numbers

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
14 Posts 4 Posters 1.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.
  • C
    Cynic @Terry R
    last edited by Oct 1, 2020, 10:22 PM

    @Terry-R It works perfectly :) Thanks a lot!

    1 Reply Last reply Reply Quote 1
    • A
      Alan Kilborn @Cynic
      last edited by Oct 2, 2020, 12:28 AM

      @Cynic said in only replace exact numbers:

      the XXX is just for any numbers really

      With the addition of this info it doesn’t seem like the regex works.

      1 Reply Last reply Reply Quote 0
      • T
        Terry R
        last edited by Oct 2, 2020, 12:31 AM

        @Alan-Kilborn said in only replace exact numbers:

        With the addition of this info it doesn’t seem like the regex works.

        Well I used the following for the test:

        0.5 something
        0.5 nothing here
        0.5434
        0.4 doesn't really matter to me
        0.5 help I'm last in line!
        

        and then after my regex was run I have:

        0.3 something
        0.3 nothing here
        0.5434
        0.4 doesn't really matter to me
        0.3 help I'm last in line!
        

        Looks like it worked. Am I missing something?

        Terry

        A 1 Reply Last reply Oct 2, 2020, 12:13 PM Reply Quote 1
        • A
          Alan Kilborn @Terry R
          last edited by Oct 2, 2020, 12:13 PM

          @Terry-R

          Nope, sorry,
          I read what the OP wanted wrongly.

          I’m (generally) not one to “shorten” regexes that work, but what about this pair as illustrating a different technique for this situation:

          find: 0\.5(?=\D)
          repl: 0.3

          1 Reply Last reply Reply Quote 3
          • O
            Olivier Thomas
            last edited by Olivier Thomas Oct 2, 2020, 12:22 PM Oct 2, 2020, 12:20 PM

            It can be like that?
            Find What:0\.5\s
            Replace With:0.3\s

            Even easier instead of \s you can insert a space

            A 1 Reply Last reply Oct 2, 2020, 12:28 PM Reply Quote 0
            • A
              Alan Kilborn @Olivier Thomas
              last edited by Oct 2, 2020, 12:28 PM

              @Olivier-Thomas said in only replace exact numbers:

              Even easier instead of \s you can insert a space

              Not necessarily.
              OP did not include info about whitespace.
              That was inferred in the example data @Terry-R provided, which may or may not be indicative of the situation the OP has.
              Unless I’m reading it wrongly yet again (very possible!).

              It really wouldn’t be up for debate if the OP had just provided the same thing we ask for here again and again and again, and most of the time we don’t get: Sample BEFORE and sample AFTER data!

              1 Reply Last reply Reply Quote 0
              • O
                Olivier Thomas
                last edited by Oct 2, 2020, 1:00 PM

                Unfortunately, I can only answer after 20 minutes.

                I am for shortening.
                instead of this
                ([2-3]|0[2-3]|00[2-3]|[2-9][2-3]|0[2-9][2-3]|\d[02-9][2-3])
                it’s better to write like this:
                ((\d[02-9]|[2-9])*)[2-3]

                A 1 Reply Last reply Oct 2, 2020, 1:09 PM Reply Quote 0
                • A
                  Alan Kilborn @Olivier Thomas
                  last edited by Oct 2, 2020, 1:09 PM

                  @Olivier-Thomas said in only replace exact numbers:

                  Unfortunately, I can only answer after 20 minutes.

                  That is because you previously ruined your reputation here.

                  I am for shortening.

                  IMO shortening something that works has little value…if we’re talking about a one-off replacement op in a text file in Notepad++.

                  Now, shortening something that is used in a production program, well, that could be a different story.

                  Sure, shortening a regex can make it more efficient.
                  But sometimes shortening a regex actually has to make the regex engine work harder (i.e., take more processing time, possibly overflow, etc) or invites more “risk”. Do we want this in a production environment? I’d say no.

                  So, the true answer, again IMO, cannot be the simple one of “I am for shortening”. But…you go ahead believing what you want to. :-)

                  Note to future readers: The regex that @Olivier-Thomas put forth in the previous posting has nothing to do with the original-poster’s problem.

                  1 Reply Last reply Reply Quote 0
                  • O
                    Olivier Thomas
                    last edited by Oct 2, 2020, 1:23 PM

                    In the IVONA voice-over for film subtitles
                    I have over 6000 abbreviated commands.

                    I did not notice that the IVONA lector did not keep up with reading the text.

                    A 1 Reply Last reply Oct 2, 2020, 1:43 PM Reply Quote 0
                    • A
                      Alan Kilborn @Olivier Thomas
                      last edited by Oct 2, 2020, 1:43 PM

                      @Olivier-Thomas said in only replace exact numbers:

                      In the IVONA voice-over for film subtitles
                      I have over 6000 abbreviated commands.
                      I did not notice that the IVONA lector did not keep up with reading the text.

                      I’m not sure what this means.
                      Do you care to explain a bit, if it is relevant?
                      After 20 minutes, of course… :-)

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