我想使用 JavaScript 和 Regex 检查测试是否仅验证管道之间的任何类型的字符串|
所以这些将测试真实
`word|a phrase|word with number 1|word with symbol?`
`word|another word`
但其中任何一个都会说假
`|word`
`word|`
`word|another|`
`word`
我试过这个
const string = 'word|another word|'
// Trying to exclude pipe from beginning and end only
const expresion = /[^\|](.*?)(\|)(.*?)*[^$/|]/g
// But this test only gives false for the first pipe at the end not the second
console.log(expresion.test(string))
交互式爱情
相关分类