2012-05-22 82 views

回答

3

這應該做的伎倆:

 String str = "2012-15 - 2012-20"; 
     String newStr = Regex.Replace(str, "(\\d+)-(\\d+)", "$1 v$2"); 
     Console.WriteLine(str); 
     Console.WriteLine(newStr); 
     Console.ReadLine(); 

打印出:

2012-15 - 2012-20

2012 V15 - 2012 V20

+0

感謝的人!!!!! –

+0

@TheKaizer:不用擔心:) – npinti

0
string input = "2012-15 - 2012-20"; 
string output = Regex.Replace(input, @"\b(-)\b", "v"); 
1

試試這個:

string input = "2012-15 - 2012-20"; 
string output = Regex.Replace(input, @"(\d{4})-(\d+)", "$1 v$2"); 
相關問題