Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: RegEx ASP.NET4.0
Hi coder i have a question which i won't be able do so may be you guys can help me
i have string which contain name in series like this
   1.WROBEL/TERESA   2.WROBEL/MAREK                                             
 1   ORD LH  433 K 28AUG 1015P OK KKNC2N   CN10   28AUG28AUG 1PC                
 2 X FRA LH 1378 K 29AUG  405P OK KKNC2N   CN10   29AUG29AUG 1PC                
 3 O GDN LO  359 W 15SEP  800A OK KKNC2N   CN10   15SEP15SEP 1PC                
 4 X FRA LH  432 K 15SEP  530P OK KKNC2N   CN10   15SEP15SEP 1PC                
i used a regex to fetch only the name from the string that is
now what i show that data in grid it show me passenger name like this
but i want it in this pattern
in the girdview for that i use split method like this
public class Detail
    string output2;
    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))
                output2 = m.ToString();
                string[] out1 = Regex.Split(output2, @"\s*\d\.\s*");             }
            return dt; 
in this first i fetch all the name in the string using (FXP\S{3,20})|(\r\s{3}.\S+(.+)) reges
and then create a array to split those name into different row but it also give me space and number and i only want name in my gridview how can i do that
thanks in advance
Posted 10-May-13 3:36am

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 9,578
1 OriginalGriff 8,420
2 Peter Leow 4,874
3 Kornfeld Eliyahu Peter 3,240
4 Maciej Los 2,356

Advertise | Privacy | Mobile
Web01 | 2.8.150327.1 | Last Updated 10 May 2013
Copyright © CodeProject, 1999-2015
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