I have a text file of a database dump with some line break characters (0x0A0x0D) in the middle of lines. I want to replace them with commas, but I can't do it simply, because those characters are the actual line break characters where I do want line breaks!But I noticed that the line break sequences I want to keep are surrouned by space characters ( 0x20), so I was thinking a regex to find and replace any 0x0A0x0D sequence without a leading or trailing space. How can I do this?
regex find and replace 0x0D, 0x0A characters
command line;text processing;shell script
The regex for a whitespace character is, of course, \s.  However, since you want a non-whitespace character, you can use \S!  Therefore, your regex to replace would be \S\n\r\S.EDIT:#!/usr/bin/perluse strict; use warnings;my $pattern = xxxxxxxxxxxxxxxxxxxy\n\ryxxxxxxxxxxxxxxxxxxx \n\r xxxxxxxxxxxxxxxxxxxy\n\ryxxxxxxxxxxxxxxxxxxx;$pattern =~ s/(\S)(\n\r)(\S)/$1$3/g;print $pattern\n;exit;result: xxxxxxxxxxxxxxxxxxxyyxxxxxxxxxxxxxxxxxxx  xxxxxxxxxxxxxxxxxxxyyxxxxxxxxxxxxxxxxxxxI changed the regex to replace with $1$3 so you retain the characters that \S matches.