Click here to Skip to main content
12,073,325 members (66,105 online)
Rate this:
 
Please Sign up or sign in to vote.
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 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
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
Top Experts
Last 24hrsThis month


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