Get part of the text (c#)

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi y'all,
I have a beginner question in c#. I need to take part of a text, based on
tags. for example:

string test = "blah blah<!--start -->1 2 3 4<!--end--> blah blah";

I want to get whatever is between the start and end tags.
result = "1 2 3 4";

Can anyone help me pls!!!
Thanks ahead,
~Jay
 
Jay said:
Hi y'all,
I have a beginner question in c#. I need to take part of a text, based on
tags. for example:

string test = "blah blah<!--start -->1 2 3 4<!--end--> blah blah";

I want to get whatever is between the start and end tags.
result = "1 2 3 4";

Can anyone help me pls!!!
Thanks ahead,
~Jay

int start = test.IndexOf("<!--start -->")+("<!--start -->").Length;
string result = test.Substring(start,test.IndexOf("<!--end-->")-start);



--
Texeme Textcasting Technology
http://texeme.com

Indie Pop Rocks @ SomaFM
http://somafm.com/
 
Jay said:
I have a beginner question in c#. I need to take part of a text, based on
tags. for example:

string test = "blah blah<!--start -->1 2 3 4<!--end--> blah blah";

I want to get whatever is between the start and end tags.
result = "1 2 3 4";

Regex.Match(test, "<!--start -->(.*)<!--end-->").Group[1].Value
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top