Community
    • Login

    How to ascend numbers?

    Scheduled Pinned Locked Moved General Discussion
    3 Posts 3 Posters 1.2k 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.
    • יואב פתאלי
      יואב פתאל
      last edited by

      Hi!
      So I have this list of items and their prices, and they’re all written in a way of X.99 . What I need to do is change the prices to X+1.00.

      Example:
      Item one $15.99
      Item two $39.99
      Item three $0.99
      Item four $7.99

      And I need this:
      Item one $16.00
      Item two $40.00
      Item three $1.00
      Item four $8.00

      I’m looking for a way to do it with notepad. I thought about firstly removing all the .99’s which is easy by replacing, then finding a way to ascend all numbers by 1 (which I don’t know how to do) then just adding .00 to the end of every line.

      So, I 'm in need of either another way of doing it, or a way to ascend numbers by one.

      Thanks in advance!

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

        If you look under the “help wanted” section for “[Regex] Rounding numbers”, about 6 months ago that will give you some information to think about.

        Regex is good at looking for strings of information, not so good at calculating, well it doesn’t calculate at all really, just counts and compares.

        It’s not impossible to do what you need with regex but it will take a lot of work.

        I’d even say Excel would do the job far easier.

        Terry

        1 Reply Last reply Reply Quote 2
        • guy038G
          guy038
          last edited by guy038

          Hello, @ואב פתאל, @terry-r and All,

          As @terry-r said, regular expressions are not the best way when calculus is involved in the process. However, if the particular case, of all decimal numbers, beginning with the $ sign and ending with the string .99, is your case, a possible regex could be :

          SEARCH (\$.*?)((0)|(1)|(2)|(3)|(4)|(5)|(6)|(7)|(8))?(?=9*\.99)|(9)

          REPLACE (?{12}0:\1(?2:1)(?{3}1)(?{4}2)(?{5}3)(?{6}4)(?{7}5)(?{8}6)(?{9}7)(?{10}8)(?{11}9))

          Of course, the Regular expression search mode must be selected and, possibly, the Wrap around option

          So, assuming the sample text, below :

          Item $0.99
          Item $1.99
          Item $2.99
          Item $3.99
          Item $4.99
          Item $5.99
          Item $6.99
          Item $7.99
          Item $8.99
          Item $9.99
          Item $10.99
          Item $11.99
          Item $12.99
          Item $13.99
          Item $14.99
          Item $15.99
          Item $16.99
          Item $17.99
          Item $18.99
          Item $19.99
          Item $20.99
          ...
          Item $39.99
          ...
          Item $98.99
          Item $99.99
          ...
          Item $9999.99
          

          it would give, after global replacement :

          Item $1.00
          Item $2.00
          Item $3.00
          Item $4.00
          Item $5.00
          Item $6.00
          Item $7.00
          Item $8.00
          Item $9.00
          Item $10.00
          Item $11.00
          Item $12.00
          Item $13.00
          Item $14.00
          Item $15.00
          Item $16.00
          Item $17.00
          Item $18.00
          Item $19.00
          Item $20.00
          Item $21.00
          ...
          Item $40.00
          ...
          Item $99.00
          Item $100.00
          ...
          Item $10000.00
          

          Voilà !

          Best Regards,

          guy038

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