I need to check if a string contains anything except the digit. But I’ve got a problem.
echo bdfbdfd | findstr /R [^0123456789]
returns nothing, but it should return bdfbdfd.
But
echo 123 | findstr /R [^0123456789]
returns ‘123’. Why? It should work vice versa.
After a lot of tests here we go:
Another way to do this is (as Christian.K stated) escaping the
^thus writing(note the
^^)For the
bdfbdfdpart putting the second regex between""and removing the space makes it work for the specified string.EDIT:
Note that you are matching a single character. In the match
nothing was matched because your string didn’t contain any digit (not counting the
^which needed to be escaped). Inyou were matching the first digit. With your regex you’ll match any string that contains a single match, so also trying to match
123(space)with the regex[^^0123456789]will output the whole string as a match because of the non-digit character in the end of the string.