Skip to content

Instantly share code, notes, and snippets.

Created January 31, 2017 18:29
Show Gist options
  • Save anonymous/e8a2939ddbbb0afcc8d6cd217f06be28 to your computer and use it in GitHub Desktop.
Save anonymous/e8a2939ddbbb0afcc8d6cd217f06be28 to your computer and use it in GitHub Desktop.
irb(main):093:0> supported_flags = ["-a","-b","-c","-d"]
=> ["-a", "-b", "-c", "-d"]
irb(main):094:0> flags_regex = Regexp.union(supported_flags.map{|i| Regexp.new("\\#{i}*")})
=> /(?-mix:\-a*)|(?-mix:\-b*)|(?-mix:\-c*)|(?-mix:\-d*)/
irb(main):095:0> "-L".match(flags_regex)
=> #<MatchData "-">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment