2017-09-23 40 views
0
string str = "Computer & Web Solution/deva/[email protected]"; 
String stre = Regex.Replace(str, @"[^0-9a-zA-Z]+", "-"); 

我的结果= Computer-Web-Solution-deva-sasasa-ww
如何获得"Computer & Web Solution/deva/[email protected]"(旧字符串)与正则表达式或其他代码如何让旧字符串Replce字符串后的正则表达式在C#

+1

获得每场比赛的原文拿什么JavaScript的在这种情况下? –

+1

从旧的变量,你可以得到旧的字符串,除非你不处理旧的值。 –

回答

0

我认为你是在谈论一个Match? 那么你需要定义像

var reg = new Regex(@"([^0-9a-zA-Z])+"); 

正则表达式,那么你就可以通过

var matches = Regex.Matches("Computer & Web Solution/deva/[email protected]"); 
foreach(var m in matches){ 
    //m.Result("$1") this is the value of each matched original text 
}