Click here to Skip to main content
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 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 George Jonsson 175
1 Kornfeld Eliyahu Peter 169
2 Zoltán Zörgő 139
3 PIEBALDconsult 130
4 OriginalGriff 120
0 OriginalGriff 6,165
1 DamithSL 4,658
2 Maciej Los 4,107
3 Kornfeld Eliyahu Peter 3,649
4 Sergey Alexandrovich Kryukov 3,342


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 10 May 2013
Copyright © CodeProject, 1999-2014
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