我猜我遇到了一个非常简单的问题,我想替换字符串中的每个逗号“,”,除了被数字包围的那些。例子:
hey, world -> hey,\nworld
hey , world -> hey,\nworld
they are simple, but now also:
hey,world -> hey,\nworld
hey),world -> hey),\nworld
(1,2) -> (1,2) << no change :P
我用不同的正则表达式尝试了它,但我真的不能让它像我想的那样容易。匹配我需要的逗号非常容易,但问题是我认为我可以这样做:
Regex.Replace(input, @"[^\d]\s*,\s*[^\d]", ",\n");
它很酷,但它改变了我的:
hey,world into: he,\norld
如果你能帮我解决这个问题,我会很高兴:)
问候, 安德鲁