I have the below string and need to get only the strings Location, Andrew Jacob
and VAAS HARI
.
p {margin-left: 0px; color: Black /style> /head> p>LocationA</p> font color=#888888>Organizer: /font> p>Andrew Jacob /p> fontcolor=#888888> Attendee(s): /font> p>VAAS HARI /p> `/head>
I tried to replace the other strings , remove or trim, but couldn't get. Please help.
答案 0 :(得分:0)
如果数据总是在同一行号上,您可以尝试这样的事情(您可能需要尝试不使用StringSplitOptions.RemoveEmptyEntries
,因为它会删除空行)
string input=@"
p {margin-left: 0px; color: Black}
LocationA
Organizer:
Andrew Jacob
Attendee(s):
VAAS HARI
";
string[] lines = input.Split("\r\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
var location = lines[1];
var organizer = lines[3];
var attendees = lines[5];
答案 1 :(得分:0)
string search = "Andrew Jacob";
int startIndex = input.IndexOf(search);
if(startIndex >= 0)
{
string output = input.Substring(startIndex, search.Length);
}
else
{
// search Not found in input
}