views:

93

answers:

2

i want to remove all text except the text in it <> from textbox use c#,dot net

A: 

This is off the top of my head, but hopefully will steer you in the right direction :)

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);
Jacob
good yar good yar
azeem
A: 

Try this

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
Nitin Chaudhari