【问题标题】:Perl - escaple new line character using regex in a file from the command linePerl - 从命令行使用正则表达式在文件中转义换行符
【发布时间】:2017-06-09 01:21:43
【问题描述】:

我有以下 CSV 文件,需要用字符“/”转义双引号内的新行

101|abc|this is desc|2017
102|xyz|"thie is a long desc
des for xyz continue here."|2017
103|abc|this is is another long desc
and it stop here"|2017

并且输出应该看起来像下面的文件。如何使用命令中的 Perl 来执行此操作?

101|abc|this is desc|2017
102|xyz|"thie is a long desc/
des for xyz continue here."|2017
103|bbb|"this is is another long desc/
and it stop here"|2017

【问题讨论】:

标签: regex perl


【解决方案1】:

通常你会像s =~ /(?:(?!\A)\G[^"\r\n]*\K|\|"[^"\r\n]*\K)(?<!\/)(\R)/\/$1/g 那样做

因为你没有表现出任何努力,所以你没有得到任何解释。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-09-27
    • 2011-08-26
    • 2012-04-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多