March 2018
Intermediate to advanced
208 pages
4h 52m
English
| | class Supply { |
| | |
| | /** |
| | * The code universally identifies a supply. |
| | * |
| » | * It follows a strict format, beginning with an S (for supply), followed |
| | * by a five digit inventory number. Next comes a backslash that |
| | * separates the country code from the preceding inventory number. This |
| | * country code must be exactly two capital letters standing for one of |
| | * the participating nations (US, EU, RU, CN). After that follows a dot |
| | * and the actual name of the supply in lowercase letters. |
| | */ |
| | static final Pattern CODE = |
| | Pattern.compile("^S\\d{5}\\\\(US|EU|RU|CN)\\.[a-z]+$"); |
| | } |
Some programming constructs are very powerful, but also very complex. Regular expressions fall into this category. ...