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
2010-07-01 01:58:00
good yar good yar
azeem
2010-07-01 02:07:40
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
2010-07-01 02:05:40