-2

我有一个像Test (123) Test& 需要从字符串中删除(123)的字符串。

请帮助我获得该 replce 的确切正则表达式模式?

Input : Test(123)Test
Output: Test Test

谢谢, Gunasekaran Sambandhan

4

1 回答 1

1

试试下面...它会帮助你...

代码 :

string input = "Test(123)Test";
string regex = "(\\(.*\\))";
string sOutput = Regex.Replace(input, regex, " ");
Console.WriteLine(sOutput);

输出 :

Test Test

更新代码:

string input = "(hi) (91) Professional Investment Services Pty Ltd (hi) (91)";
Regex regex = new Regex(string.Format("\\{0}.\\d+\\{1}", '(', ')'));
Console.WriteLine(regex.Replace(input, string.Empty));

输出 :

(hi) Professional Investment Services Pty Ltd (hi)
于 2013-04-11T09:59:35.783 回答