aboutsummaryrefslogtreecommitdiffstats
path: root/rust
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2019-05-20 15:00:39 -0700
committerBryan Newbold <bnewbold@robocracy.org>2019-05-20 15:00:39 -0700
commit510dc33c55b1aa993fc3e0e7085184ecbda8ef04 (patch)
tree3ded1231d4d83094ebb8edd2ff1e9b072937bb7f /rust
parentb888f2201f981a2e01026e53d5c6ba2d435e9506 (diff)
downloadfatcat-510dc33c55b1aa993fc3e0e7085184ecbda8ef04.tar.gz
fatcat-510dc33c55b1aa993fc3e0e7085184ecbda8ef04.zip
allow versioned PMCID
Diffstat (limited to 'rust')
-rw-r--r--rust/src/identifiers.rs7
1 files changed, 5 insertions, 2 deletions
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<()> {