Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    How to replace spaces with commas

    General Discussion
    2
    2
    31567
    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.
    • Angelica Sarina
      Angelica Sarina last edited by

      Hi, I want to replace my spaces with commas. Every time, I put “replace all” it replaces the spaces with commas, but it forms just a single line. I still want to keep the same format. How do I do that? Thank you for your help.

      Input:
      15 21 24 32 65 11,3
      07 25 39 40 47 20,3

      Desired Output:
      15, 21,24,32 ,65,11,3
      07,25, 39, 40,47,20,3

      Instead Of:
      15, 21,24,32 ,65,11,3,07,25, 39, 40,47,20,3

      1 Reply Last reply Reply Quote 0
      • guy038
        guy038 last edited by

        Hello, @angelica-sarina,

        I don’t really understand how your search/replacement could have gotten rid of all the line-breaks !

        Indeed, assuming the input text, below :

        15 21 24 32 65 11,3
        07 25 39 40 47 20,3
        
        • Open the Replace dialog Ctrl + H

        • Type in a single space character, in the Find what: zone

        • Type in a , character, in the Replace with: zone

        • Select the Normal search mode

        • Click on the Replace All button

        And you obtain the output :

        15,21,24,32,65,11,3
        07,25,39,40,47,20,3
        

        Now, if your numbers may be separated by more than one space, as below :

        15   21 24     32     65 11,3
        07         25   39 40 47       20,3
        

        Here is a second solution :

        • Open the Replace dialog Ctrl + H

        • Type in a \x20+ character, in the Find what: zone

        • Type in a , character, in the Replace with: zone

        • Select the Regular expression search mode

        • Click on the Replace All button

        And, magically, you get the expected output :

        15,21,24,32,65,11,3
        07,25,39,40,47,20,3
        

        Best Regards,

        guy038

        1 Reply Last reply Reply Quote 2
        • First post
          Last post
        Copyright © 2014 NodeBB Forums | Contributors