Hello C#ers
I am trying to create a parser in asp.net c# and have all the tags split into an array however.... the ending of the tags have code that I need to strip and I dont know how to do this. I need to cut out all the text that follows '>'.
right now I have something like
a[0] = body>text asdasd
a[1] = form>sadasdasdasdas
how do I just go delete all including > and after.
so that its
a[0] = body
a[1] = form
Thanks,
Riv
I am trying to create a parser in asp.net c# and have all the tags split into an array however.... the ending of the tags have code that I need to strip and I dont know how to do this. I need to cut out all the text that follows '>'.
right now I have something like
a[0] = body>text asdasd
a[1] = form>sadasdasdasdas
how do I just go delete all including > and after.
so that its
a[0] = body
a[1] = form
Thanks,
Riv
AlanPosted Nov 3, 2007, 5:42 PM
There are various ways of doing this but the one I like best is to use the Split() method:
a[0] = "body>text asdasd";
a[1] = "form>sadasdasdasdas";
a[0] = a[0].Split('>')[0]; // "body"
a[1] = a[1].Split('>')[0]; // "form"