Community
    • Login

    Remove forced 70-80 char line limit from multiple text files

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    5 Posts 3 Posters 908 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.
    • FreshensteinF
      Freshenstein
      last edited by

      I have a few dozen very old text files and in each paragraph the lines are broken into lines of 70-80 characters. What would the RegEx expression be so that I could go about deleting those line breaks and making each paragraph one long line?

      Example:

      This is all a paragraph
      blah blah blah
      ETC

      into:

      This is all a paragraph blah blah blah ETC

      1 Reply Last reply Reply Quote 0
      • Pierre ÅbergP
        Pierre Åberg
        last edited by

        Not sure if this is the “best way” to do it, but I would try something like:

        Find what: \s
        Replace with: “space”

        This would result in:
        This is all a paragraph blah blah blah ETC

        After that I would do it again but this time with
        Find what: \s\s
        Replace with: “space”

        This would result in:
        This is all a paragraph blah blah blah ETC

        FreshensteinF 1 Reply Last reply Reply Quote 0
        • FreshensteinF
          Freshenstein @Pierre Åberg
          last edited by

          @Pierre-Åberg
          That just made the entire document as one giant line, which is not what I asked for. I need it to make each paragraph a single line.

          PeterJonesP 1 Reply Last reply Reply Quote 0
          • PeterJonesP
            PeterJones @Freshenstein
            last edited by PeterJones

            @Freshenstein ,

            If I start with:

            This is all a paragraph
            blah blah blah
            ETC
            
            This is a second paragraph
            blah
            and this ends the second paragraph
            
            
            • FIND WHAT = (?<!\r\n)\r\n(?!\r\n)
            • REPLACE WITH = space character
            • SEARCH MODE = regular expression
            • REPLACE ALL

            This finds newline sequences (\r\n = CRLF = carriage return + line feed = standard Windows end-of-line) that don’t have a newline sequence before ((?<!\r\n) means “look behind for not CRLF”) and don’t have a newline sequence after ((?!\r\n) means “look ahead for not CRLF”) and replaces them with a space.

            => then I end up with:

            This is all a paragraph blah blah blah ETC
            
            This is a second paragraph blah and this ends the second paragraph 
            
            

            ----

            Useful References

            • Please Read Before Posting
            • Template for Search/Replace Questions
            • Formatting Forum Posts
            • Notepad++ Online User Manual: Searching/Regex
            • FAQ: Where to find other regular expressions (regex) documentation

            ----

            Please note: This Community Forum is not a data transformation service; you should not expect to be able to always say “I have data like X and want it to look like Y” and have us do all the work for you. If you are new to the Forum, and new to regular expressions, we will often give help on the first one or two data-transformation questions, especially if they are well-asked and you show a willingness to learn; and we will point you to the documentation where you can learn how to do the data transformations for yourself in the future. But if you repeatedly ask us to do your work for you, you will find that the patience of usually-helpful Community members wears thin. The best way to learn regular expressions is by experimenting with them yourself, and getting a feel for how they work; having us spoon-feed you the answers without you putting in the effort doesn’t help you in the long term and is uninteresting and annoying for us.

            1 Reply Last reply Reply Quote 6
            • FreshensteinF
              Freshenstein
              last edited by

              That is EXACTLY what I was wanting. Thanks so much!

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