요즘 SIP, MSRP, RTP 등의 프로토콜 스택 작업을 많이 하다 보니
문자열과 문자열 사이의 값을 가져올 일이 많아졌습니다.
"동해물과 백두산이 마르고 닳도록" 에서..
"동해물과", "마르고" 를 넣으면 " 백두산이 "를 리턴합니다.
public static string GetMiddleString(string str, string begin, string end)
{
if (string.IsNullOrEmpty(str))
{
return null;
}
string result = null;
if (str.IndexOf(begin) > -1)
{
str = str.Substring(str.IndexOf(begin) + begin.Length);
if (str.IndexOf(end) > -1) result = str.Substring(0, str.IndexOf(end));
else result = str;
}
return result;
}TCP 까고, Header/Body 까고, 문자열 까고.. 지겨운 작업..





감사합니다.^