From e0ed339ad5596e98101087505b72fb35a07b160b Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 9 Jan 2018 17:13:41 -0300 Subject: [PATCH] Bug 11046: Improve the readability of the regex using named capture The tests tell me I am good Signed-off-by: Jonathan Druart --- C4/Biblio.pm | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index b910f40d1f..b9c46554b1 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -2700,12 +2700,15 @@ sub _adjust_pubyear { $retval = $1; } elsif( $retval =~ m/(\d\d\d\d)/ && $1 > 0 ) { $retval = $1; - } elsif( $retval =~ m/(\d)[.Xx?]{3}|(\d\d)[.Xx?]{2}|(\d{3})[.Xx?]/ ) { - my $digits = $1 || $2 || $3; - $retval = $digits * ( 10 ** ( 4 - length($digits) )); - } elsif( $retval =~ m/(\d)[-]{3}\?|(\d\d)[-]{2}\?|(\d{3})[-]\?/ ) { - # the form 198-? occurred in Dutch ISBD rules - my $digits = $1 || $2 || $3; + } elsif( $retval =~ m/ + (?\d)[-]?[.Xx?]{3} + |(?\d{2})[.Xx?]{2} + |(?\d{3})[.Xx?] + |(?\d)[-]{3}\? + |(?\d\d)[-]{2}\? + |(?\d{3})[-]\? + /xms ) { # the form 198-? occurred in Dutch ISBD rules + my $digits = $+{year}; $retval = $digits * ( 10 ** ( 4 - length($digits) )); } return $retval; -- 2.39.5