Community
    • Login

    How to replace spaces with commas

    Scheduled Pinned Locked Moved General Discussion
    2 Posts 2 Posters 72.5k Views 1 Watching
    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 SarinaA Offline
      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
      • guy038G Offline
        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 1

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors