Click here to Skip to main content
15,887,416 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a large string in which two small string are same but not exactly what i want is to select only one string from that large string not the other string

this is my string

C#
RP/NYC1S21DD/NYC1S21DD            WS/SU   6MAY13/0503Z   29WHVE  // i want to select   29WHVE                  
 NYC1S21DD/9525GY/6MAY13                                                         
  1.KHOON/FRANCIS   2.MEH/SAY   3.MEH/PRAY   4.MEH/MAW                          
  5.REH/LAW   6.REH/PAE   7.REH/DO   8.REH/LEE   9.REH/HEH                      
  10  US 152 T 12MAY 7 GEGPHX HK9   300P 534P 12MAY  E  US/A4PRHM                
)>SP1                                  
RP/NYC1S21DD/NYC1S21DD            WS/SU   6MAY13/0503Z   XXXXXX   //i dont want to select This XXXXXX             
 1.KHOON/FRANCIS                                                              
 2  US 152 T 12MAY 7 GEGPHX HK1   300P 534P 12MAY  E  US/A4PRHM  


SQL
i want to select 29WHVE not XXXXXX

i have many string like that this is only one string which i show here for this i used \s[A-Z0-9]{6}\s{12} regex
Posted
Comments
siddharthrainit 24-May-13 9:57am    
do you want to select string from comment portion
amitesh1989 24-May-13 10:24am    
i made some changes in my function and it done thank

1 solution

Follow the below steps:

1.Split the whole string by newline by using array.

2.iterate all the values in array.

3.in loop check if string starts with "RP/NYC1S21DD/NYC1S21DD"

4.when you get that string replace space(" ") with pipe (|).

5.split that string with pipe (|) take those values in array.

6.select last value from the array and apply regex to it.

Hope it hepls
 
Share this answer
 
Comments
amitesh1989 24-May-13 10:25am    
thanks nirav but i made some changes in my function which call that regex and it work

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