File tree 2 files changed +5
-3
lines changed
main/java/ru/mystamps/web/service
test/groovy/ru/mystamps/web/service
2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ public class SeriesInfoExtractorServiceImpl implements SeriesInfoExtractorServic
47
47
48
48
// Regular expression matches release year of the stamps (from 1840 till 2099).
49
49
private static final Pattern RELEASE_YEAR_REGEXP =
50
- Pattern .compile ("18[4-9][0-9]|19[0-9]{2}|20[0-9]{2}" );
50
+ Pattern .compile ("( 18[4-9][0-9]|19[0-9]{2}|20[0-9]{2})г? " );
51
51
52
52
// Regular expression matches number of the stamps in a series (from 1 to 99).
53
53
private static final Pattern NUMBER_OF_STAMPS_REGEXP = Pattern .compile (
@@ -183,12 +183,13 @@ protected Integer extractReleaseYear(String fragment) {
183
183
184
184
String [] candidates = StringUtils .split (fragment );
185
185
for (String candidate : candidates ) {
186
- if (!RELEASE_YEAR_REGEXP .matcher (candidate ).matches ()) {
186
+ Matcher matcher = RELEASE_YEAR_REGEXP .matcher (candidate );
187
+ if (!matcher .matches ()) {
187
188
continue ;
188
189
}
189
190
190
191
try {
191
- Integer year = Integer .valueOf (candidate );
192
+ Integer year = Integer .valueOf (matcher . group ( 1 ) );
192
193
log .debug ("Release year is {}" , year );
193
194
return year ;
194
195
Original file line number Diff line number Diff line change @@ -239,6 +239,7 @@ class SeriesInfoExtractorServiceImplTest extends Specification {
239
239
' 2010\t\t brazil' | _
240
240
' 2010 brazil' | _
241
241
' prehistoric animals 2010 congo' | _
242
+ ' 2010г' | _
242
243
}
243
244
244
245
@SuppressWarnings (' UnnecessaryGetter' )
You can’t perform that action at this time.
0 commit comments