Click here to Skip to main content
11,647,170 members (70,744 online)
Rate this: bad
good
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
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
(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
WROBEL/TERESA
WROBEL/MAREK

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 2:36am

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

  Print Answers RSS
0 jyo.net 500
1 OriginalGriff 337
2 DamithSL 310
3 Sergey Alexandrovich Kryukov 265
4 CPallini 249
0 OriginalGriff 1,277
1 jyo.net 994
2 DamithSL 946
3 Sergey Alexandrovich Kryukov 853
4 CPallini 760


Advertise | Privacy | Mobile
Web03 | 2.8.150804.2 | 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