我如何向自己保证字符串只包含数字和竖线(或还有)逗号、字符?EG:所有字符都只有数字和管道或数字、逗号和管道
EG:
1|2,2|3 = true
1|2 = true
bob = false
bob|yes,no = false
这是我目前为止
if (preg_match('/^[0-9|]|[0-9,|]+$/', $str)){
//if all of the characters are only numbers and pipes or numbers, commas and pipes only
}