Click here to Skip to main content
15,890,185 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
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
C#
FXP/R,U                                                                         
   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                
     ORD                                                          


i used a regex to fetch only the name from the string that is
C#
(FXP\S{3,20})|(\r\s{3}.\S+(.+))


now what i show that data in grid it show me passenger name like this
1.WROBEL/TERESA 2.WROBEL/MAREK

but i want it in this pattern
C#
WROBEL/TERESA
WROBEL/MAREK


in the girdview for that i use split method like this

C#
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

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