如何使用正则表达式 ( ) 替换这些尾随"N megapixels"
字符串?""
RegEx.Replace
例子:
如果我们输入:“Powershot Yellow 12.1 Megapixels”,结果将是:“Powershot Yellow”
如果我们输入:“Powershot Black II 10 Megapixels”,结果将是:“Powershot Black II”
如何使用正则表达式 ( ) 替换这些尾随"N megapixels"
字符串?""
RegEx.Replace
例子:
如果我们输入:“Powershot Yellow 12.1 Megapixels”,结果将是:“Powershot Yellow”
如果我们输入:“Powershot Black II 10 Megapixels”,结果将是:“Powershot Black II”
像这样简单的东西怎么样...
var newStr = Regex.Replace(input, @"\s+[\d\.]+\s*Megapixels", "", RegexOptions.IgnoreCase);
试试这个:
var newString = Regex.Replace(candidate, @"\d+\.?\d+ Megapixels", "");
var camera = Regex.Replace(input, @"\s+[.\d]+\s+Megapixels", "", RegexOptions.IgnoreCase);