Community
    • Login

    Numbers to words converter

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    7 Posts 3 Posters 2.6k 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.
    • Alwin CrosseA
      Alwin Crosse
      last edited by Alwin Crosse

      Hello…Is there a way to convert a number sequence to words (digit-wise) in Notepad++ or any other software? For example…8749264 -> Eight Seven Four Nine Two Six Four? All the numbers to words converters on the internet convert numbers to billions, millions etc. For example…Eight Million, Seven Hundred etc…

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

        @alwin-crosse said in Numbers to words converter:

        Is there a way to convert a number sequence to words (digit-wise) in Notepad++

        Yes, indeed. It uses what is called a regular expression. So using the Replace Function we have:
        Find What:(0)|(1)|(2)|(3)|(4)|(5)|(6)|(7)|(8)|(9)
        Replace With:(?{1}Zero )(?{2}One )(?{3}Two )(?{4}Three )(?{5}Four )(?{6}Five )(?{7}Six )(?{8}Seven )(?{9}Eight )(?{10}Nine )

        You need to set the search mode to “regular expression”. You can click on “Replace” or “Replace All” buttons. The first will replace ONLY the next instance, whereas the other button changes all numbers in the tab/file.

        Note I have included a space character after each word. That will mean this might end up adding a space before an end of sentence if a number is the last character. As an example 386. becomes Three Eight Six ., note the space between six and the DOT character.

        Terry

        Terry RT 2 Replies Last reply Reply Quote 6
        • Terry RT
          Terry R @Terry R
          last edited by

          @terry-r said in Numbers to words converter:

          You can click on “Replace” or “Replace All” buttons. The first will replace ONLY the next instance, whereas the other button changes all numbers in the tab/file.

          There’s also a method to just change 1 multi-digit number with a single click. See the image below:

          38f52faa-e3b7-41ef-a174-a2054641d486-image.png

          So the Replace function is loaded as per previously. Use the mouse to select the area to convert (it will be highlighted with a background colour). Then in the Replace function click on the “In Selection” button, then click on “Replace All” button. It will change just what is selected.

          Terry

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

            @terry-r said in Numbers to words converter:

            That will mean this might end up adding a space before an end of sentence if a number is the last character. As an example 386. becomes Three Eight Six ., note the space between six and the DOT character.

            I had a thought overnight on how my solution might be improved. The issue I referred to was the final space character added where it wasn’t needed for the last digit. In my example I showed a multi-digit number immediately before a punctuation mark. In my example it was a DOT, although could easily be a comma, semi-comma or even inside of parentheses, any non-digit in fact.

            So I made an improvement, here it is:
            Find What:(?:(0)|(1)|(2)|(3)|(4)|(5)|(6)|(7)|(8)|(9))((?=\d))?
            Replace With:(?{1}Zero)(?{2}One)(?{3}Two)(?{4}Three)(?{5}Four)(?{6}Five)(?{7}Six)(?{8}Seven)(?{9}Eight)(?{10}Nine)(?{11} )

            So for anyone wanting a description, here it is:
            The first set of parentheses is a non-capture one (?:…), this avoids the need to change all numbering in the replacement field. Here we look for any of the numbers 0 to 9. Each number is also in it’s own capture group and in the replacement field that numbered capture group is used to replace the number with its associated word.

            The ((?=\d))? is another capture group surrounding a positive lookahead, this capture group includes the final ?, this means the capture group does not need to actually capture if there is no number ahead. This is the 11th capture group and in the replacement there is a test for this 11th capture. If that test (a number ahead) was true it then adds a space after the word.

            Terry

            Alwin CrosseA 1 Reply Last reply Reply Quote 4
            • guy038G
              guy038
              last edited by guy038

              Hello, @alwin-crosse, @terry-r and All,

              Regarding this topic, here is two variations which may interest some people :

              • Changing numbers, between 0 and 999, into letter-numbers :

              https://sourceforge.net/p/notepad-plus/discussion/331753/thread/171471a4/#59f6

              and the regex explanations, in the last post :

              https://sourceforge.net/p/notepad-plus/discussion/331753/thread/171471a4/#cacb

              • Changing letter-numbers, between 0 and 999, into numbers :

              https://sourceforge.net/p/notepad-plus/discussion/331753/thread/52cf361c/#8edf


              In order to verify that every number is correctly translated :

              • Open an empty tab

              • Hit 10 times on the Enter key

              • Open the Replace dialog ( Ctrl + H )

                • SEARCH (?-s)^\R

                • REPLACE $0$0$0$0$0$0$0$0$0$0

                • Tick the Wrap around option

                • Select the Regular expression search mode

                • Click twice on the Replace All button

              => You’ll get a list of 1000 empty lines

              • Open the column editor option ( Alt + C )

                • Choose the radio button Number to Insert

                • Initial number 0

                • Increase by : 1

                • Repeat 1

                • Untick the Leading zeros option

                • Click on the OK button

              • Delete the last number 1000

              • Run the Edit > Blank Operations > Trim Trailing Space option


              Now, use, for instance, this regex S/R :

              SEARCH (((1)|(2)|(3)|(4)|(5)|(6)|(7)|(8)|(9))?((0)|(1)|(2)|(3)|(4)|(5)|(6)|(7)|(8)|(9)))?((0)|(1)|(2)|(3)|(4)|(5)|(6)|(7)|(8)|(9))

              REPLACE $0\t\t=>\t(?3one)(?4two)(?5three)(?6four)(?7five)(?8six)(?9seven)(?10eight)(?11nine)(?2 hundred(?13(?24: and ): and ))(?15twenty)(?16thirty)(?17forty)(?18fifty)(?19sixty)(?20seventy)(?21eighty)(?22ninety)(?12(?14:(?13:(?24:-))))(?14(?24ten)(?25eleven)(?26twelve)(?27thirteen)(?28fourteen)(?29fifteen)(?30sixteen)(?31seventeen)(?32eighteen)(?33nineteen):(?25one)(?26two)(?27three)(?28four)(?29five)(?30six)(?31seven)(?32eight)(?33nine))(?1:(?24zero))

              You should get :

              0		=>	zero
              1		=>	one  
              2		=>	two  
              3		=>	three  
              4		=>	four  
              5		=>	five  
              ...
              ...
              995		=>	nine hundred and ninety-five 
              996		=>	nine hundred and ninety-six 
              997		=>	nine hundred and ninety-seven 
              998		=>	nine hundred and ninety-eight 
              999		=>	nine hundred and ninety-nine 
              

              Finally :

              • Move to the very beginning of the new tab

              • Do a 1000×8 rectangular selection and hit the Delete key

              • Move again at the very beginning

              And, for instance, use the reverse regex S/R :

              SEARCH (((one)|(two)|(three)|(four)|(five)|(six)|(seven)|(eight)|(nine)) hundred and )?((((twenty)|(thirty)|(forty)|(fifty)|(sixty)|(seventy)|(eighty)|(ninety))(-((one)|(two)|(three)|(four)|(five)|(six)|(seven)|(eight)|(nine)))?)|(ten)|(eleven)|(twelve)|(thirteen)|(fourteen)|(fifteen)|(sixteen)|(seventeen)|(eighteen)|(nineteen)|((one)|(two)|(three)|(four)|(five)|(six)|(seven)|(eight)|(nine))( hundred)?)|(zero)

              REPLACE (?{3}1)(?{4}2)(?{5}3)(?{6}4)(?{7}5)(?{8}6)(?{9}7)(?{10}8)(?{11}9)(?{15}2)(?{16}3)(?{17}4)(?{18}5)(?{19}6)(?{20}7)(?{21}8)(?{22}9)(?{23}(?{25}1)(?{26}2)(?{27}3)(?{28}4)(?{29}5)(?{30}6)(?{31}7)(?{32}8)(?{33}9):(?{14}0))(?{34}10)(?{35}11)(?{36}12)(?{37}13)(?{38}14)(?{39}15)(?{40}16)(?{41}17)(?{42}18)(?{43}19)(?{1}(?{44}0))(?{45}1)(?{46}2)(?{47}3)(?{48}4)(?{49}5)(?{50}6)(?{51}7)(?{52}8)(?{53}9)(?{54}00)(?{55}0)\t\t=\t\($0\)

              You’ll obtain :

              0		=	(zero)
              1		=	(one)
              2		=	(two)
              3		=	(three)
              4		=	(four)
              5		=	(five)
              ...
              ...
              995		=	(nine hundred and ninety-five)
              996		=	(nine hundred and ninety-six)
              997		=	(nine hundred and ninety-seven)
              998		=	(nine hundred and ninety-eight)
              999		=	(nine hundred and ninety-nine)
              

              Best Regards,

              guy038

              1 Reply Last reply Reply Quote 4
              • Alwin CrosseA
                Alwin Crosse
                last edited by

                This post is deleted!
                1 Reply Last reply Reply Quote 0
                • Alwin CrosseA
                  Alwin Crosse @Terry R
                  last edited by Alwin Crosse

                  @terry-r Oh my God Terry and guy038…That was an absolutely awesome explanation. Thank you so very much for taking the time to answer my question in such a clear and indepth way. I am very thankful and grateful to youll for all the help.

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