当我没有在“这里”一词之前插入任何不在[,.]中的符号时,此正则表达式查询运行良好:
RegEx.Replace("My products or something / else here ", "My ((?:[a-z']* ??)*?)\s*([,.]|$| here)", "")
但是如果我在“这里”之前插入一个不在[,.]中的符号,它会非常非常慢(冻结大约 3-5 秒或更长时间) 。例如,我在“这里”一词之前插入符号“/”:
RegEx.Replace("My products or something / else here ", "My ((?:[a-z']* ??)*?)\s*([,.]|$| here)", "")
当我将 / 添加到我的模式[,.]时,问题就消失了:
RegEx.Replace("My products or something / else here ", "My ((?:[a-z']* ??)*?)\s*([/,.]|$| here)", "")
但我希望我的正则表达式忽略符号 / 而不是匹配符号 / 作为我句子的结尾。为什么会出现这个问题以及如何解决?