repl.bat:在替换参数中使用正则表达式

时间:2014-11-03 23:32:25

标签: batch-file replace

关于使用' repl'我有一个问题。批处理命令,特别是它的替换参数。

花时间阅读文档......: - )......以及一些测试,似乎不能在替换参数中使用正则表达式。

"输入file.txt | repl"雅各布还活着。他活着。\ n" "贝蒂活着。\ n去贝蒂。" M> file.txt.new"

这将使用字符'进行文字替换。' &安培; ' \ n'而不是插入新的行。是否真的正则表达式不能在repl.bat的[replace]参数中使用?如果没有,你知道一种实现这种行为的方法吗?提前谢谢!

1 个答案:

答案 0 :(得分:0)

摘自repl.bat /?信息

    M - Multi-line mode. The entire contents of stdin is read and
        processed in one pass instead of line by line, thus enabling
        search for \n. This also enables preservation of the original
        line terminators. If the M option is not present, then every
        printed line is termiated with carriage return and line feed.
        The M option is incompatible with the A option unless the S
        option is also present.

    X - Enables extended substitution pattern syntax with support
        for the following escape sequences within the Replace string:

        \\     -  Backslash
        \b     -  Backspace
        \f     -  Formfeed
        \n     -  Newline
        \q     -  Quote
        \r     -  Carriage Return
        \t     -  Horizontal Tab
        \v     -  Vertical Tab
        \xnn   -  Extended ASCII byte code expressed as 2 hex digits
        \unnnn -  Unicode character expressed as 4 hex digits

因此,您的repl命令选项应该是MX而不是M