I want to have a regex for NAME;NAME;NAME and also for NAME;NAME;NAME;NAME where the fourth occurrence of NAME is optional.
I have one regex as (.+);(.+);(.+) which matched the first pattern but not the second. I tried playing with ? but its not working out with (.+);(.+);(.+)(;(.+))? Basically, I want to achieve the fourth (.+) as zero or one occurence.