Take the 2-minute tour ×  How would you go about creating a
random alpha-numeric string that matches a certain regular
expression?  This is specifically for creating initial passwords
that fulfill regular password requirements.  share|improve this
question  10 Answers 10  Welp, just musing, but the general
question of generating random inputs that match a regex sounds
doable to me for a sufficiently relaxed definition of random and
a sufficiently tight definition of regex. I'm thinking of the
classical formal definition, which allows only ()|* and alphabet
characters.  Regular expressions can be mapped to formal
machines called finite automata. Such a machine is a directed
graph with a particular node called the final state, a node
called the initial state, and a letter from the alphabet on each
edge. A word is accepted by the regex if it's possible to start
at the initial state and traverse one edge labeled with each
character through the graph and end at the final state.  One
could build the graph, then sta