Regex.Replace("some big text", "^.+(big).+$", "$1"); // "big"
Regex.Replace("some small text", "^.+(big).+$", "$1"); // "some small text", but i need here empty string
我需要从字符串中选择一个值。没关系,当字符串匹配模式。但是当字符串不匹配时,替换结果中会有一个原始字符串。我需要一个空字符串,当字符串不匹配模式(只使用替换)。空置换结果,当正则表达式不匹配时
我知道这一点,但我不能使用Regex.Match方法。我只能使用替换。 我使用雅虎管道,并且只有选择值的replce功能。我无法在之前添加匹配方法。 – chardex 2010-02-05 13:32:58