我正在尝试在继续解析字符串之前对其进行规范化。基本上删除逗号之前或之后的所有空格,如果两个或多个逗号仅由空格分隔,则替换为单个逗号。
var r = new Regex(@"(\s*,+\s*)");
var query = r.Replace("my reg, is a disaster everytime , i,try ,it, yep, ,disaster.", ",");
输出应该是:
my reg,is a disaster everytime,i,try,it,yep,disaster.
但它的:
my reg,is a disaster everytime,i,try,it,yep,,disaster.
任何帮助表示赞赏