The last '?' seems to make no sence (at least to me). I think you wanted to use reluctant matches to avoid getting the greatest possible match, but I don't see the application here. Also '-{0}?' seems a bit odd...

Regex! Yep, it's cool but it's (1) hard to write and (2) hard for read. Why not make it easy on yourself and others? You have to show me first some people that really understand it to convince me it is great.

The last '?' seems to make no sence (at least to me). I think you wanted to use reluctant matches to avoid getting the greatest possible match, but I don't see the application here. Also '-{0}?' seems a bit odd...

Do you mind posting a complete example with the correponding java code.

I have not really thought about the whole context, so I am afraid the problem lies in referencing the match brackets. If you use a single bracket with {m,n}, you won't (to my knowledge) be able to reference the single matches, afaik only the last match will be returned... So I think you are stuck with your working "expanded" version of the regex.

Edit:s/match bracket/capturing group/g so I am essentially saying the same as pepijnve below

<inigo-montoya>You keep using that term. I do not it means what you think it means.</inigo-montoya>

I think you may be overgeneralizing the problem. Correct me if I'm wrong, but all you want to do is split each line into each "word", right? Then you need to test if you have three or four columns on that line. So something like this should do the trick:

Let me start off my saying that I am partial to StringTokenizers! BUT, if you read a line and pass that to a tokenizer then getting the first token will tell you whether the data will have 3 or 4 parts to it. Unless the sample you posted isnot representative! For example:

I was hoping regex would be more powerful.I don't like string tokenizers due to the fact that regex is more powerful and much more natural to process IMO.I know how to use regex normaly however I wanted to further simplify my reg ex command to take into effect multiple variables.Now that I know that it isn't possible I guess it's time to lobby Sun over added regex functionality.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org