I have facing problem for creating a Regex that accept any string other than all dashes i.e. if string contains all the dashes it should be rejected.
i tried [0-9-]* but it accept all dashes
and -*[0-9]+ it does what i want but don’t allows shuffling(I mean mixed string of 0-9 and -(dash)).
for example trt-09tr- should be accepted.
—rte434rt should be accepted.
– should be rejected.
—— should be rejected.
—6 accepted.
–u accepted.
if some one could help me.
thank you
You want negative lookahead for that, one that matches the whole input:
(?!^-+$).*prints