Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def symbol_chars_are_valid(symbol_chars)
- # :aaa == :"aaa" if it has valid Symbol literal chars
- eval ":#{symbol_chars} == :#{symbol_chars.inspect}"
- rescue Exception
- false
- end
- chars_to_try =
- '`~!@$%^&*()-_+={}[]|\;:"<>,.?/'.split('') + ["'"] +
- ('A'..'Z').to_a + ('a'..'z').to_a + ('0'..'9').to_a
- puts "valid as first char:"
- puts chars_to_try.select {|c| symbol_chars_are_valid "#{c}aa" }.join ''
- puts "valid as middle char:"
- puts chars_to_try.select {|c| symbol_chars_are_valid "a#{c}a" }.join ''
- puts "valid as end char:"
- puts chars_to_try.select {|c| symbol_chars_are_valid "aa#{c}" }.join ''
Add Comment
Please, Sign In to add comment