re = /^[ \t]*((none|dotted|dashed|solid|double|groove|ridge|(?:in|out)set|hidden|inherit|initial|revert|unset){1}([ \t]+(none|dotted|dashed|solid|double|groove|ridge|(?:in|out)set|hidden|inherit|initial|revert|unset)){0,3})[\t ]*$/m
str = '
none
dotted
dashed
dotted dotted
dashed dashed dashed
solid solid solid solid
inset outset
# Errors - must not match
nonee
dotte2d
dashed-
dotted -dotted
dasheddashed dashed
solid fake solid solid'
# Print the match result
str.scan(re) do |match|
puts match.to_s
end
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html