正则表达式CSV替换引号之间的逗号

问题描述:

我们有这样的字符串:

"COURSE",247,"28/4/2016 12:53 Europe/Brussels",1,"Verschil tussen merk, product en leveranciersverantwoordelijke NL","Active Enro"

目标是替换merk,product之间的逗号,并保留逗号,和,&,,以便我们可以正确地分割文件。

The Goal is to replace the comma between "merk, product" and to keep the comma like "," and ", & ," so we can split the file correctly.

有任何建议吗?

感谢

首先,您应该检查 了解CSV文件及其在ABAP中的处理

First of all, you should check Understanding CSV files and their handling in ABAP article.

对于一次性作业,您可以使用此正则表达式(但请注意,对于较长的字符串,它可能无法正常工作,使用它作为最后手段):

For a one-time job, you can use this regex (but note that with longer strings, it may not work well, use it as a means of last resort):

,(?!(?:[^"]*"[^"]*")*[^"]*$)

请参阅 regex演示

See the regex demo

模式详情


  • code>, - 一个逗号...

  • 后跟.... ....


    • (?: -


      • [^] * - 零个或多个字符而非 li>
      • - 双引号

      • [^] - 见上文

      • , - a comma that...
      • (?! - is not followed with....
        • (?: -
          • [^"]* - zero or more chars other than "
          • " - a double quote
          • [^"]*" - see above