create a password with at least one uppercase letter in ruby

To create a password with at least one uppercase letter in Ruby, you can use a regular expression to check if the password contains at least one uppercase letter.

Here's an example:

main.rb
def create_password
  password = ""
  until password =~ /.*[A-Z].*/ do
    puts "Enter a password with at least one uppercase letter:"
    password = gets.chomp
  end
  return password
end
189 chars
9 lines

This code uses a while loop to prompt the user to enter a password until the password contains at least one uppercase letter. The regular expression /.*[A-Z].*/ matches any string that contains at least one uppercase letter.

Note that this is just one example of how to create a password with at least one uppercase letter in Ruby. There are many ways to accomplish this task.

gistlibby LogSnag