Hello! I'm trying to type pattern for non-negative numbers. When I execute the following command:
nothing is printed (there is no match found). How to fix it? I expected 2223 as output.
Here are some examples:
I wan't to understand which syntax to use to write
I know that I can use Bash on Windows (via Cygwin for instance) but it is interesting to figure out how to use regex in cmd.
Code:
echo 2223 | findstr /r "^[0-9][0-9]*$ ^+[0-9][0-9]*$"
Here are some examples:
- Input: "2223", Output: "2223"
- Input: "a2223", Output: ""
- Input: "2223b", Output: ""
- Input: "a", Output: ""
- Input: "a 2223", Output: ""
- Input: "2223 b", Output: ""
I wan't to understand which syntax to use to write
'^[0-9]+$'
grep equivalent:
Bash:
echo "2223" | grep --color -E '^[0-9]+$'
Last edited: