-3

Using any popular tool on a GNU/Linux system (python, sed, awk, *sh, ...), I would like to output a list of all the words which match a given regex. Unlike the examples I found, I do not want to retrieve the list of the words from a given text which match the regex. For example, if the regex is "[aA]foo", I would like to have a tool which outputs:

afoo
Afoo

If the regex matches an inifinite number of words (eg. "a*"), I do not expect it to be smart, it may crash or whatever.

I would like to have the output in a file with one word per line (or in any format I can redirect to a file). The expected ouput size is about 20K words.

Edit

Using the keyword "generate" from the duplicate proposition, I think this question is more a duplicate of this one: Using Regex to generate Strings rather than match them

Community
  • 1
  • 1
elkami
  • 1
  • 1
  • Good luck with that impossible task – Kovpaev Alexey Aug 05 '16 at 23:20
  • 1
    Possible duplicate of [Generate all matches for regex](http://stackoverflow.com/questions/21517428/generate-all-matches-for-regex) – Barmar Aug 05 '16 at 23:35
  • My question may be too broad and does not relate to the real regular expressions. I just need the "brackets" and the "curly braces" functionalities. For example, I would like to "expand" [A-Zbc]{1,4}foo[aA]. This is definitely possible. Is there another synthax language I should try for this particular purpose ? – elkami Aug 05 '16 at 23:43

1 Answers1

1

Such a tool does not exist since it is technically impossible. In many cases there are infinitely many matching strings, quite often they have variable length. One cannot construct a tool for that, it goes beyond the limit of possibility.

Rafael Albert
  • 445
  • 2
  • 8