Click here to Skip to main content
13,054,329 members (121,388 online)
Rate this:
Please Sign up or sign in to vote.
I have a list of name in series like:
  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
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

--- TST RLR ---                                                                 
RP/NYC1S21DD/NYC1S21DD            WS/SU   6MAY13/0503Z   29WHVE                 
  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  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:

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 10-May-13 0:38am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Have a look at below example:
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());
            // Suspend the screen.

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. ;)

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 11 May 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100