Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here you should use string operation and regular expression. I solved your problem. Please run my code and let me know if you have any doubt. </p> <pre><code> int startindex = request.IndexOf(" 1 "); request = request.Substring(startindex - 1); //Remove the special character line from the input string subs; while (request.Trim() != "&gt;") // Here we create the loop for execute whole string. { int r1 = request.IndexOf("\r", 3); subs = request.Substring(0, r1); // Here we take the first line of the input. dr = dt.NewRow(); // Here we create the new row for each line. MatchCollection m1 = Regex.Matches(subs, @"\w{3}\s\d"); // Take the LAS 1 character from the line for merging the seat availability classes value. string origin = m1[0].Value; // Here we assign the origin city name to string variable. string destination = m1[1].Value; // Here we assign the destination city name to string variable. int end = subs.IndexOf(origin); int start = end - 1; dr["Origin"] = origin; // Here we bind the origin city name to data column. dr["Destination"] = destination; // Here we bind the destination city name to data column. request = request.Substring(subs.Length); // Here requset variable contain the substring after the took of first line for processing. r1 = request.IndexOf("\r\n", 3); // Here we are taking the index of second line. string replace = request.Substring(3, r1).TrimStart(); string result = subs.Substring(0, start) + replace + subs.Substring(end); // here we merge the seat availability classes value. Regex regex = new Regex(@"(\s(\w\w\s){2,})"); // Here we create the regular expression for seat availability classes. Match match1 = regex.Match(result); dr["COS"] = match1.ToString(); // Here we bind the seat availability classese to data column. dr["Segment"] = result.Substring(0, result.IndexOf(match1.ToString()) - 2); // Here we bind the Segments to data column. subs = result; start = subs.IndexOf(destination); dr["Details"] = subs.Substring(start + 5); // Here we bind the further(timing details) details of flight to data column. dt.Rows.Add(dr); // Here we are binding whole rows to data table. request = request.Substring(r1); // requset variable contains the remaining substring. } GridView1.DataSource = dt; GridView1.DataBind(); // Here we are binding the whole data table to GridView. dt.Dispose(); // Here we dispose the datatable and free the memory. </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload