From: Mi Ni Date: 2008-01-31T23:16:59+09:00 Subject: Reverse RegEx or How to write a KeywordGenerator for a given im new to ruby and have not the deep knowledge of all the possible ways to get a solution. but for to the sequence generator im very surprised of the clean short ruby solution.. My Goal: write a parser for some patterns to generate some keywords from it. RegEx? i can have some regex to test some text, but is there a reverse way: generate from a given regex all possible mutations for it? what i found until now? i have found a sequence generator http://snippets.dzone.com/posts/show/3332 witch i can give this pattern: x = [['abc'],['','-'],['def'],['','n'],['123','456']] and get this permutations/sequences: abcdef123 abcdef456 abcdefn123 abcdefn456 abc-def123 abc-def456 abc-defn123 abc-defn456 but i will not will not write this difficult arrays. i like a light pattern syntax to generate this arrays and permutations for instance for the given pattern: "abc-defn?[123|456]" i will generate this array: x = [['abc'],['','-'],['def'],['','n'],['123','456']] some rules: ? => means one or not | => mens OR [] => braces "-" => replace with this "-?" "ä" "ö" "ü" "ß" => automaticly goes to "[ä|ae]" or "[ü|ue]" or "[ö|oe]" or "[ss]" in combination with () and some $1 $2 i can generate some RegEx like substitutions with ${varname} i can include some predefined big patternlists i like also use recursive patterns: "[123[1|2]|45]" etc. Solutions? i can cut the strings with some string replace etc. but i think this is not the good ruby way. is a DSL parser/generator the right way for it? which one is the best for it (ParseTree/TreeTop/GhostWheel/ can someone give me some routing directions where i can look for the best ruby way for my idea? -- Posted via http://www.ruby-forum.com/.