Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
3.50/5 (2 votes)
I have a list of name in series like:
VB
1.KHOON/FRANCIS   2.MEH/SAY   3.MEH/PRAY   4.MEH/MAW
  5.REH/LAW   6.REH/PAE   7.REH/DO   8.REH/LEE   9.REH/HEH



now what i want is to show these name in grid like this
KHOON/FRANCIS
MEH/SAY
MEH/PRAY
MEH/MAW and so on i dont want number and . into grid.

how can i do that i am using asp.net4.0 web application

for example i have a string like this

C#
RT29WHVE
--- TST RLR ---                                                                 
RP/NYC1S21DD/NYC1S21DD            WS/SU   6MAY13/0503Z   29WHVE                 
NYC1S21DD/9525GY/6MAY13                                                         
  1.KHOON/FRANCIS   2.MEH/SAY   3.MEH/PRAY   4.MEH/MAW                          
  5.REH/LAW   6.REH/PAE   7.REH/DO   8.REH/LEE   9.REH/HEH   
  10.AMitesh/verma                   
 10  US 152 T 12MAY 7 GEGPHX HK9   300P 534P 12MAY  E  US/A4PRHM                
 11  US 184 T 12MAY 7 PHXLAS HK9   815P 923P 12MAY  E  US/A4PRHM                
 12  US 392 K 13MAY 1 LASCLT HK9   115A 827A 13MAY  E  US/A4PRHM                
 13  US4286 K 13MAY 1 CLTFAY HK9   955A1050A 13MAY  E  US/A4PRHM                
     OPERATED BY SUBSIDIARY/FRANCHISE                                           
 14 MIS 1A HK9 NYC 11JAN-THANK YOU FOR YOUR BUSINESS                            
 15 AP NYC9103161516                                                            
 16 APE FRANCISKHON@GMAIL.COM                                                   
 17 TK OK06MAY/NYC1S21DD//ETUS                                                  
 18 SSR DOCS US HK1 ////09NOV83/M//KHOON/FRANCIS/P1                             
 19 SSR DOCS US HK1 ////01JAN92/M//MEH/SAY/P2                                   
 20 SSR DOCS US HK1 ////01JAN62/M//MEH/PRAY/P3                                  
 21 SSR DOCS US HK1 ////01JAN96/M//MEH/MAW/P4                                   
 22 SSR DOCS US HK1 ////15APR89/M//REH/LAW/P5                                   
 23 SSR DOCS US HK1 ////11NOV97/M//REH/PAE/P6                                   
 24 SSR DOCS US HK1 ////01JAN59/M//REH/DO/P7                                    
 25 SSR DOCS US HK1 ////05OCT88/M//REH/LEE/P8


now i create a function where i use my coding part like this:


C#
public class Detail
    {
        string output;
        DataTable dt = new DataTable();
        DataRow dr = null;
         public DataTable GetDetail(List<string> request, List<string> Request)
         {
                string item = data;
                dr = dt.NewRow();
                Regex regex1 = new Regex(@"(FXP\S{3,20})|(\r\s{3}.\S+(.+))", RegexOptions.IgnoreCase | RegexOptions.Compiled);
                foreach (Match m in regex1.Matches(data))
                {
                    output = m.ToString();
                }
                   dr["Passenger Name"] = output;
                 }
                return dt; 
               }
         }
}}

in this i get result in the same row
Posted

1 solution

Have a look at below example:
C#
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string sPattern = "(?:[0-9]{1,2}\\.)(?<Name>[A-Za-z]{1,}/[A-Za-z]{1,})";
            Regex r = new Regex(sPattern , RegexOptions.ExplicitCapture | RegexOptions.Singleline | RegexOptions.Compiled );

            string sPath = "E:\\data.txt";
            string line = String.Empty;

            System.IO.StreamReader file = new System.IO.StreamReader(sPath);
            while ((line = file.ReadLine()) != null)
            {
                //Console.WriteLine("Processing line: {0}",line);
                foreach (Match m in r.Matches(line))
                {
                    Console.WriteLine ("Match: {0}" ,m.ToString());
                }
            }
            file.Close();

            // Suspend the screen.
            Console.ReadLine();

        }
    }
}


Result:
Match:  1.KHOON/FRANCIS
Match:  2.MEH/SAY
Match:  3.MEH/PRAY
Match:  4.MEH/MAW
Match:  5.REH/LAW
Match:  6.REH/PAE
Match:  7.REH/DO
Match:  8.REH/LEE
Match:  9.REH/HEH
Match:  10.AMitesh/verma


As you can see, i have saved your input string into text file, then i read it line by line. ;)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900