I'm supposed to check whether a string matches a certain pattern. The pattern is as follows
dd.mm.yyyy HH:mm;score;duration
- notice the space between yyy and HH
- score being an int value
- duration being a double value
How to construct a regex pattern concerning the above problem? What have I missed in my code or have done wrong?
I'm mainly confused about the special characters like semicolon, colon, space bar and when to use \
or \\
public HighscoreEntry(String data) {
String pattern= "^(3[01]|[12][0-9]|0?[1-9])\\.\\(1[0-2]|0?[1-9])\\.\\(20[0-9]{2})\\s\\(2[0-4]|[01][0-9])\\:\\(5[0-9]|[0-4][0-9]\\;\\d+\\;\\d*\\.\\d+$";
if(data.matches(pattern)){
...