-1

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.

Erik Philips
  • 53,428
  • 11
  • 128
  • 150
VaasLolla
  • 51
  • 1
  • 1
  • 5

2 Answers2

0

If the data's always on the same line number you could try something like this (you may need to try without StringSplitOptions.RemoveEmptyEntries as that'll remove blank lines)

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];
stevieg
  • 652
  • 4
  • 14
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
}
yazanpro
  • 4,512
  • 6
  • 44
  • 66
  • 1
    While this might possibly be the correct answer, it doesn't look convincing without commentaries and only code. Please consider adding a commentary for a better chance of being accepted. – Gokhan Kurt Dec 02 '16 at 06:12
  • Thankyou ,but the output is dynamic ...so it may not be Andrew Jacob Or LocationA always ... – VaasLolla Dec 03 '16 at 11:21