Remove forced 70-80 char line limit from multiple text files
-
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
ETCinto:
This is all a paragraph blah blah blah ETC
-
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 ETCAfter 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 -
@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. -
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.
- FIND WHAT =
-
That is EXACTLY what I was wanting. Thanks so much!