送信者の一般的な場所を地理的に特定するプログラムを作成しましたが、たとえば、文字列からIPアドレスを抽出する際に問題が発生します。
public static string getBetween(string strSource, string strStart, string strEnd)
{
int Start, End;
if (strSource.Contains(strStart) && strSource.Contains(strEnd))
{
Start = strSource.IndexOf(strStart, 0) + strStart.Length;
End = strSource.IndexOf(strEnd, Start);
return strSource.Substring(Start, End - Start);
}
else
{
return "";
}
//完全なEMAILのMIMEデータを文字列(txtEmail)にキャプチャしました//文字列を検索します...
//THIS IS MY PROBLEM. this is always different.
// I need to capture only the IP address between the brackets
string findIP = "X-Originating-IP: [XXX.XXX.XXX.XXX]";
string data = getBetween(findIP, "[", "]");
txtCustomIPAddress.Text = data;
何か案は?