I want to Split the url into two part using RegEx. I have saved the xml response into datatable and iterate through the each row using foreach. When I use the datatable value for regEx only 0 will be available. When I use the array index 1 it give the following Exception.
System.IndexOutOfRangeException: Index was outside the bounds of the array.
The Following is gives and Exception.
foreach (DataRow row in ndt.Rows)
{
string imgurl =row["image1"].ToString();
String[] fimgurl = Regex.Split(imgurl, @"small/");
String simgurl = fimgurl[1];
}
The Following It's working without any issue.
foreach (DataRow row in ndt.Rows)
{
//TextBox1.Text = row["ImagePath"].ToString();
string imgurl ="http://www.hotelbeds.com/giata/small/12/124356/124356a_hb_w_001.jpg";
String[] fimgurl = Regex.Split(imgurl, @"small/");
String simgurl = fimgurl[1];
}
I Have saved the same url as string in My Datatable. I couldn't find what's wrong with that. Can anyone please help me on this?
imgurlobviously doesn't equalhttp://www.hotelbeds.com/giata/small/12/124356/124356a_hb_w_001.jpg??