You can also use grep, it is more complicated:
egrep "|.*|.*|" input
echo No pipe
egrep "^[^|]*$" input
echo One pipe
egrep "^[^|]*|[^|]*$" input
echo 3+ pipe
egrep "|[^|]*|[^|]*|" input
Before combining the greps, first introduce new variables
p (pipe) and n (no pipe)
p="|"
n="[^|]*"
echo "p=$p, n=$n"
echo No pipe
egrep "^$n$" input
echo One pipe
egrep "^$n$p$n$" input
echo 3+ pipe
egrep "$p$n$p$n$p" input
Now bring all together
egrep "^$n$|^$n$p$n$|$p$n$p$n$p" input
Edit: The comments and variable names were about "slashes", but they are pipes (with backslashes). That was a bit confusing.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…