Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# RegEx ASP.NET4.0
I have case. I want to select multiple passenger names from the input. if input contains only single passenger name then avoid that input string.
 
I have create regular expression in which It's work for multiple names from the input but it's not work, when I want to avoid single passenger name in the input.
 
My aim is to select only those case who contain multiple passenger names not the single passenger name.
 
for example: This is the input string where in one string i have single pax and in other i have more than one pax what i want is to create a regex which match with more than one pax.
 
string ymt4 = @"RP/NYC1S21DD/NYC1S21DD            WS/SU   6MAY13/0509Z   Y39ZRG                
NYC1S21DD/80948W/6MAY13                                                        
  1.CORTES RIVERA/MARIA(ADT)  ";// only one pax
 
string ymt5 = @"RT29PVZU
--- TST RLR MSC ---                                                            
RP/NYC1S21DD/NYC1S21DD            WS/SU   6MAY13/0452Z   29PVZU                
NYC1S21DD/9999WS/6MAY13                                                        
  1.ALVARADO/RITA(ADT)   2.CABELLO/LUIS CARLOS(ADT)                            
  3.CABELLO/CINDY(ADT)   4.GUTIERREZ/MARTHA HILDA(ADT) ";//more than one pax
 
Regex i used for it is \d\.[a-zA-Z]\S(.+)
 
The main problem with this regex is that is match single as well as multiple pax where as i only want to match single pax. That's why i want you help guys
 
Thanks in advance
Posted 9-May-13 1:44am
Edited 9-May-13 2:20am
v5
Comments
OriginalGriff at 9-May-13 6:49am
   
No, I'm not going to a random website and looking to see what the heck you are talking about.
If you want us to help, make it easy for us: explain your problem properly, and give samples of what you expect in and what you want to match.
Help us to help you - and show you have put some effort into thinking about it!
Use the "Improve question" widget to edit your question and provide better information.
OriginalGriff at 9-May-13 7:08am
   
Better, but you still need to show us what you expect to match - remember that we have no idea what problem you are trying to solve, and we can't see your screen or access your HDD.
 
To us, that is just a pile of text, with nothing that says "this is a name" or "this is two names" There are a lot of bits in both samples that could be a name.
amitesh1989 at 9-May-13 7:30am
   
i already done that mate by mistake i paste wrong link. And now i explain everything their u can check and if you think you know the answer you can tell me
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

try this regex @"[0-9]*\.[A-Za-z]*"
example
string ymt4 = @"RP/NYC1S21DD/NYC1S21DD            WS/SU   6MAY13/0509Z   Y39ZRG                
NYC1S21DD/80948W/6MAY13                                                        
  1.CORTES RIVERA/MARIA(ADT)  ";// only one pax
 
string ymt5 = @"RT29PVZU
--- TST RLR MSC ---                                                            
RP/NYC1S21DD/NYC1S21DD            WS/SU   6MAY13/0452Z   29PVZU                
NYC1S21DD/9999WS/6MAY13                                                        
  1.ALVARADO/RITA(ADT)   2.CABELLO/LUIS CARLOS(ADT)                            
  3.CABELLO/CINDY(ADT)   4.GUTIERREZ/MARTHA HILDA(ADT) ";//more than one pax
MatchCollection matches = Regex.Matches(ymt4 , @"[0-9]*\.[A-Za-z]*");
if(matches.Count>1)
     MessageBox.Show(matches.Count.ToString());
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

i use this regex (2\.[A-z]\S(.+)) it will fetch multiple pax and avoid single pax
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 7,903
1 Sergey Alexandrovich Kryukov 7,192
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,820


Advertise | Privacy | Mobile
Web04 | 2.8.1411023.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