From 510dc33c55b1aa993fc3e0e7085184ecbda8ef04 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Mon, 20 May 2019 15:00:39 -0700 Subject: allow versioned PMCID --- rust/src/identifiers.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'rust/src') diff --git a/rust/src/identifiers.rs b/rust/src/identifiers.rs index fead4272..37305677 100644 --- a/rust/src/identifiers.rs +++ b/rust/src/identifiers.rs @@ -106,7 +106,7 @@ fn test_check_username() { pub fn check_pmcid(raw: &str) -> Result<()> { lazy_static! { - static ref RE: Regex = Regex::new(r"^PMC\d+$").unwrap(); + static ref RE: Regex = Regex::new(r"^PMC\d+(\.\d+)?$").unwrap(); } if raw.is_ascii() && RE.is_match(raw) { Ok(()) @@ -121,9 +121,12 @@ pub fn check_pmcid(raw: &str) -> Result<()> { #[test] fn test_check_pmcid() { assert!(check_pmcid("PMC12345").is_ok()); + assert!(check_pmcid("PMC12345.1").is_ok()); + assert!(check_pmcid("PMC12345.96").is_ok()); assert!(check_pmcid("PMC12345 ").is_err()); assert!(check_pmcid("PMC").is_err()); - assert!(check_pmcid("PMC1.2345").is_err()); + assert!(check_pmcid("PMC.3").is_err()); + assert!(check_pmcid("PMC1123.").is_err()); } pub fn check_pmid(raw: &str) -> Result<()> { -- cgit v1.2.3