Is there a Linux command or software library that returns a list of strings matching a regex it is given as input?
For example, \d
would return 0
, 1
, 2
, 3
, 4
, 5
, 6
, 7
, 8
, and 9
.
Given that regexes are already quite power-consuming I'd be really suprised if this was the case. Still, if such a solution does not exist, what alternatives are there?
If using a python parsing module is an option, there is a pyparsing script to expand a regular expression into "all" possible matching strings.
Using its invert(regex)
function, the code
for text in invert('\d'):
print(text)
will have the output
0
1
2
3
4
5
6
7
8
9