Programming Journal C#, Java, SQL and to a lesser extent HTML, CSS, XML, and regex. I made this so other programmers could benefit from my experience.

Friday, December 14, 2007

C# string extract tag method

This extracts a tagged string. For example, string findTagValue = extractTag ("Foo", "", ""); This would fetch Foo.

private string extractTag(string original, string beginTag, string endTag)
{
string retVal = string.Empty;
int begin = original.IndexOf(beginTag);
int end = -1;
if (begin > 0)
{
end = original.IndexOf(endTag, begin);
}
if ((begin > 0))
{
if ((end > begin))
{
retVal = original.Substring((begin+beginTag.Length), (end - begin-endTag.Length));
}
}
return retVal;
}

2 comments:

Anonymous said...

Greetings guys. I am only I start to study c programs.
I have visited a site http://program.v3host.be/?cat=204.
Much to our regret I have very little found out about it.
You can probably tell to me a good site about c programing.
I will be very glad.
Thansk

Anonymous said...

Greetings man. I am only I start to study c program array.
I have visited a site http://program.v3host.be/?cat=204.
Much to our regret I have very little found out about it.
You can probably tell to me a good site about c program example.
I will be very glad.
Thansk