My question sounds trivial, but I google many page still can't not find an answer.
I am on Windows. I have a text file. If I open it with Notepad++, it looks like this
I want to try several things
perl -i.bak -pe "s/\r\n//g" a.txt
perl -i.bak -pe "s/^(function.*\r\n)!/$1\t!/g" a.txt
perl -i.bak -pe "s/\n//" a.txt
I.e. just change
\n for the
\r\n is automatically converted to
\n on Windows as it was explained by ikegami.
perl -i.bak -0777 -pe "s/^(function.*?\n)!/\1\t!/gm" a.txt
The main point here is that you need to read the entire file contents into a single string in order to do cross-line matches.
-0777 parameter instructs Perl to do so (alternatively you may set
$/ to a string from within Perl script).