I am trying to parse input string using regular expression. I am getting problem when trying to capture a repeating group. I always seem to be matching last instance of the group. I have tried using Reluctant (non greedy) quantifiers, but I seems to be missing some thing. Can someone help?
Regular expression tried:
(OS)\s((\w{3})(([A-Za-z0-9]{2})|(\w{3})(\w{3}))\/{0,1}){1,5}?\r
(OS)\s((\w{3}?)(([A-Za-z0-9]{2}?)|(\w{3}?)(\w{3}?))\/{0,1}?){1,5}?\r
Input String:
OS BENKL/LHRBA/MANQFL
I always seem to capture last group which is MANQFL group (MAN QFL)
, and my aim is to get all three groups (there can be 1-5 groups):
(BEN KL) , (LHR BA) and (MAN QFL).
Anyhelp will be appreciated.
See Question&Answers more detail:os