2010-07-01 233 views
-1

以外的不需要的文本我想从文本框中删除除<>之外的所有文本。删除<>

+0

请澄清什么是你想做的事 - 删除除该字符以外的所有文本< and >或删除除< and >之间包含的任何文本之外的所有文本。 – 2010-07-01 01:37:20

+0

therir是这样的电子邮件www.abc.com <[email protected]> ,我想删除多余的文字这个“www.abc.com” – azeem 2010-07-01 01:50:00

回答

1

这是从我的头顶,但希望将引导你在正确的方向:)

String email = "www.abc.com <[email protected]>"; 
String result = ""; 

int firstIndex = email.IndexOf('<'); 
int lastIndex = email.IndexOf('>'); 
if(lastIndex > firstIndex) 
    result = email.Substring(firstIndex + 1, lastIndex-firstIndex-1); 
+0

好yar好yar – azeem 2010-07-01 02:07:40

1

试试这个

var strText = "asdasd<data1>sdsdf <data2>sdfsfsdf"; 
var pattern = new Regex(@"\<(?<data>(.+?))\>"); 
var matches = pattern.Matches(strText); 
foreach (Match match in matches) 
{ 
    Console.WriteLine("Data: " + match.Groups["data"]); 
} 
//Output: 
//Data: data1 
//Data: data2 
相关问题