Well, I'm stuck on a regular expression problem. I have a JTextField that is used to enter a range of pages. For example 11-21, 45-49. However I want to use Regex to pull this data as groups. So group one will be 11-21 and two will be 45-49. Lol I've been messing with this regex for about 3 hours and google searching all morning. However I just can't seem to get this to come together. This is what I have so far.
The issue is the comma and the space. I want to match it but exclude from group. I tried look arounds but cant seem to get this going. It matches one group but nothing more than this. As soon as I test with comma and space m.matches() returns false. Anything will be helpful. Thank you all.
Your regex only has one group in it, so that is all it will find. I wouldn't try to fiddle and get more out of it, instead I would use Matcher#find() in a while loop to find all occurrences of the pattern in the input. Each loop should give you one group which represents one range of pages, which you process accordingly.
I'm so happy! And I wish to make this tiny ad happy too: