我一直在尝试找到一种方法来识别输入表单上的 DOI 以触发特定搜索。我在这里找到了一个 DOI 正则表达式,当我将它与Match或Test一起使用时,我得到 'NULL' 和 Error 作为结果
function checkDOI(string){
//Redundant. I know
var testKey = String(string);
var DOIpattern = '\b(10[.][0-9]{4,}(?:[.][0-9]+)*/(?:(?!["&\'<>])\S)+)\b';
var found = DOIpattern.test(testKey);
console.log("found", found + " DOI "+ testKey);
return found
}
checkDOI("10.1016.12.31/nature.S0735-1097(98)2000/12/31/34:7-7")
我收到了这个错误DOIpattern.test is not a function
然后,如果我将 found.test 更改为 MATCHvar found = DOIpattern.match(testKey);
结果为空
有人可以告诉我我做错了什么吗?
预先感谢!