我正在尝试用换行符替换文本行中的每个第6个逗号。我试过用文本板中的\ n替换{6}而没有运气。有任何想法吗?
答案 0 :(得分:2)
/^(([^\n,]+,){5}[^\n,]+),\s*/gm
的 \1\n
应该可以正常工作,具体取决于您的风格。
/^((.*?,){5}.*?),\s*/gm
也可以正常工作,但你不能使用DOTALL修饰符。
<强>输入:强>
this, is, my, string, and, it, is, very, nice, and, pretty, cool
this, is, my, string, and, it, is, very, nice, and, pretty, cool
this, is, my, string, and, it, is, very, nice, and, pretty, cool
this, is, my, string, and, it, is, very, nice, and, pretty, cool
this, is, my, string, and, it, is, very, nice, and, pretty, cool¨
<强>输出:强>
this, is, my, string, and, it
is, very, nice, and, pretty, cool
this, is, my, string, and, it
is, very, nice, and, pretty, cool
this, is, my, string, and, it
is, very, nice, and, pretty, cool
this, is, my, string, and, it
is, very, nice, and, pretty, cool
this, is, my, string, and, it
is, very, nice, and, pretty, cool