I want to check with JavaScript & Regex that a test only validates any kind of string between pipes |
So these will test true
`word|a phrase|word with number 1|word with symbol?`
`word|another word`
But any of these will say false
`|word`
`word|`
`word|another|`
`word`
I have tried this
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))
.split("|")job to me..