windows批处理如何替换换行符?
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了windows批处理如何替换换行符?相关的知识,希望对你有一定的参考价值。
windows批处理如何替换换行符?使用Windows批处理,如何把txt文本中的所有linux换行符全部替换为Windows换行符?代码如何写?
@(for /f "delims=" %%i in (old.txt) do @(set /p a=%%i<nul&echo.))>>new.txt
其中old.txt对应你要读取的文件,new.txt对应新产生的文件,请自行改成其他的。但是不能是同一个文件名,因为不能一边读取一边写入同一个文件。另外,最好在该命令前先执行:
del /f /q new.txt
因为“>>”是追加写入。
参考技术A代码如下:
@echo off
setlocal enabledelayedexpansion
set lf=^
(for /f "delims=" %%i in (1.txt) do (
set "$=%%i"
for %%a in ("!lf!") do echo !$:, =%%~a!
))>2.txt
pause
代码无法达到预期的结果,请调试。
代码存在错误。
Notepad++替换格式符号(如换行符Tab符等)
(前提是要选中 正则表达式模式)
查找目标 | 替换为 | 说明 |
---|---|---|
, | 在行尾加上逗号 | |
替换为空,即合并多行内容为一行 | ||
把 windows 下的换行符替换为 linux 下的换行符 | ||
把 替换为空,即把 windows 下的换行符替换为 Mac 下的换行符 | ||
, | 把逗号全部替换成换行 | |
去掉空行 | ||
1ss | 1 | 去掉 1 后的两个空格,其中一个 s 表示一个空格 |
1两个半角空格 | 1 | 可以直接在 1 后跟两个半角空格来匹配,跟上面 s 是一样的效果 |
在每行行首添加制表符,即四个半角空格的效果 |
版权声明:本文为CSDN博主「媛测」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/lijing742180/java/article/details/85174564
Extended Search Mode
In extended mode, these escape sequences (a backslash followed by a single character and optional material) have special meaning, and will not be interpreted literally.
: the Line Feed control character LF (ASCII 0x0A)
: The Carriage Return control character CR (ASCII 0x0D)
: the TAB control character (ASCII 0x09)
: the NUL control character (ASCII 0x00)
: the literal backalash character (ASCII 0x05C)
: the binary representation of a byte, made of 8 digits which are either 1’s or 0’s. ?
o: the octal representation of a byte, made of 3 digits in the 0-7 range
d: the decimal representation of a byte, made of 3 digits in the 0-9 range
x: the hexadecimal representation of a byte, made of 2 digits in the 0-9, A-F/a-f range.
u: The hexadecimal representation of a two byte character, made of 4 digits in the 0-9, A-F/a-f range. In Unicode builds, finds a Unicode character (for instance, u2020 matches the ? char, in an UTF-8 encoded file). In ANSI builds, finds characters requiring two bytes, like in the Shift-JIS encoding. ?
?NOTE: While some of these Extended Search Mode escape sequences look like regular expression escape sequences, they are not identical. Ones marked with ? are different from or not available in regular expressions.
来源: https://npp-user-manual.org/docs/searching/#extended-search-mode
以上是关于windows批处理如何替换换行符?的主要内容,如果未能解决你的问题,请参考以下文章