Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
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.

C#
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
Updated 9-May-13 1:20am
v5
Comments
OriginalGriff 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 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 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

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());
 
Share this answer
 
v2
i use this regex (2\.[A-z]\S(.+)) it will fetch multiple pax and avoid single pax
 
Share this answer
 

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