I need to Extract data from text file and write it into excel file. I’m attaching input text file and in that file we have few lines which start with L1*<<,L2*<<,L3*<<,… Ln*.
After the “L” line we have a 6 character length line which is PNR line. Immediately after the PNR line, passenger names start. Each passenger is given a number as 1.1, 2.1, 3.1, 4.1, 5.I etc.
the number of occurrences of 1.1,2.1,3.1 is not static it varies. Hence I need extract it in a dynamic way.
Any leads in helping in extraction is much appreciated.
Your regex code to extract names is grouping entire 4 to 5 lines of data. I only need to extract what ever the lines which has 1.1,2.1,3.1,…etc and I dont need the data of lines starting with EY to getting in the group.
once the block is extracted then for postprocessing we can do the filtering - e.g. evaluating the start part
split the lines by
arrPassengers = strPassengerBlock.Split({Environment.NewLine}, StringSplitOptions.None)
then filter arrPassengers
We would also recommend to reformulate/recheck the filter criterias. Currently we would understand that following is requested:
Line starts with digit-dot-digit - regex: \d\.\d
Could you please help me more in detail. I’m looping all the matches in for each loop and I have set the type argument to “system.text.regularexpressions.regex.match”. and When I use the split expression which was provided by you in the same for each loop to split the data I encounter error which says split is not a member of “system.text.regularexpressions.regex.match”.