This is not related to any game I’m developing, so that’s why I don’t post it here.
Here is my pattern code
Matcher m = Pattern.compile("\\[((.*?),|)(\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2})(,(.*?)|)\\]").matcher(text);
The problem I have with it that I want to be able to write things like this
[text,2014-09-09 19:00:00]
[text,2014-09-09 19:00:00,text]
[2014-09-09 19:00:00,text]
[2014-09-09 19:00:00]
What I want to happen is.
((.?),|) = Return any text without the “,” or null
(,(.?)|) = Return any text without the “,” or null
(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}) = Returns time and date in, yyyy-mm-dd hour:min:sec format
When I test with this [2014-09-09 19:00:00] I get these group
0: [2014-09-09 19:00:00]
1:
2: null
3: 2014-09-09 19:00:00
4:
and I can’t understand why group 4 isn’t null like group 2