diff --git a/pass-data-client/src/main/java/org/eclipse/pass/support/client/ModelUtil.java b/pass-data-client/src/main/java/org/eclipse/pass/support/client/ModelUtil.java index d77ddfd5..ebe9e4ed 100644 --- a/pass-data-client/src/main/java/org/eclipse/pass/support/client/ModelUtil.java +++ b/pass-data-client/src/main/java/org/eclipse/pass/support/client/ModelUtil.java @@ -43,7 +43,8 @@ public static String normalizeAwardNumber(String awardNumber) { } //if matching the NIH format, then normalize it to the expected format by removing leading zeros - if (awardNumber.toUpperCase().matches("[0-9]*-*\\s*[A-Z]{1,2}[0-9]{1,2}\s*[A-Z]{2}[A-Z0-9]{6}-*[A-Z0-9]*")) { + if (awardNumber + .toUpperCase().matches("[0-9]*-*\\s*[A-Z]{1,2}[0-9]{1,2}[A-Z]?\s*[A-Z]{2}[A-Z0-9]{6}-*[A-Z0-9]*")) { //remove leading zeros, whitespace and make uppercase awardNumber = awardNumber .replaceFirst("^0+-*(?!$)", "") diff --git a/pass-data-client/src/test/java/org/eclipse/pass/support/client/ModelUtilTest.java b/pass-data-client/src/test/java/org/eclipse/pass/support/client/ModelUtilTest.java index d4233ec8..db25098a 100644 --- a/pass-data-client/src/test/java/org/eclipse/pass/support/client/ModelUtilTest.java +++ b/pass-data-client/src/test/java/org/eclipse/pass/support/client/ModelUtilTest.java @@ -27,10 +27,13 @@ public void testNullAndEmptyAwardNumber() throws IOException { public void testNihAwardNumberCorrectFormatWithSpace() throws IOException { String awardNumber1 = "K99 NS062901"; String awardNumber2 = "P50 AI074285"; + String awardNumber3 = "P2C HD042854"; String awardNumber1Expected = "K99NS062901"; String awardNumber2Expected = "P50AI074285"; + String awardNumber3Expected = "P2CHD042854"; assertEquals(awardNumber1Expected, ModelUtil.normalizeAwardNumber(awardNumber1)); assertEquals(awardNumber2Expected, ModelUtil.normalizeAwardNumber(awardNumber2)); + assertEquals(awardNumber3Expected, ModelUtil.normalizeAwardNumber(awardNumber3)); } @Test