function to replace ASCII CR & LF chars eg by spaces
-
Hello, notepad has a function to replace ASCII CR & LF codes eg by spaces?
ThankS -
You can use the Regular Expression mode of Notepad++'s search-and-replace function:
Search > Replace
(often mapped to Ctrl+H)- Find What: “
[\r\n]
” => find either CR or LF - Replace With: "
- Search Mode:
☑ Regular Expression
(the quotes are there to make the space obvious; don’t include the quotes)
However, that will cause windows-style EOL (CR+LF) to become two spaces
If you want a CR+LF to become one space, while still converting singleton CR or singleton LF to one space, change to- Find What: “
\r\n|[\r\n]
” => find either CR+LF or CR or LF
(keeping the other options the same)
- Find What: “
-
Thanks
Some codes or characters are difficult to remember, then as a suggestion for notepad ++ developers, in the field search please add a table of characters for the purpose of easily paste them
idea
http://eonicasys.com.co/public/math/CAS/hp_prime/chars/images/chars_hp_prime_image00.png
http://eonicasys.com.co/public/math/CAS/hp_prime/chars/images/chars_hp_prime_image01.png
-
@PeterJones and @ElectrONICs-And-SYStems
You can also use the simpler “\R” to represent any of the various forms of line endings.
-
The idea from @ElectrONICs-And-SYStems is not bad. Before I had ultraedit and they have some kind of help in the search dialog to build regex:
https://www.ultraedit.com/support/tutorials-power-tips/ultraedit/regular-expression-builder.html
Also the favorites in the search I used at that time a lot
https://www.ultraedit.com/support/tutorials-power-tips/ultraedit/search-replace-favorites.html
When you not need the regex frequently then it is a nice hint to get back in the syntax.
-
@ElectrONICs-And-SYStems There is somewhat of a help for characters and codes in ASCII included with Notepad++. In the Edit menu, select Character Panel, and it will display the ASCII characters and codes.
@MaDill The Find/Replace dialog box does save some number of recent searches; however, it does not allow you to save favorites like the program you used appears to. I know there’s been some discussion on how many searches can be saved, and how to possibly increase that.
It’s not a bad suggestion, but some users posting here claim that each RegEx is generally unique. However, I for one, do like to have someplace to start when I create a RegEx. Currently, I use a text file with significant RegEx strings and descriptions of them. A limited number of “favourites” would be helpful.