I need to find a section of a string that includes the substring
log = "username: jsmith\nprint time: 08:02:41\npower level: 9001" print_time = log.match(/print time:\s*([^\n]+)\s*\n/) p print_time # => "08:02:41"
/print time:\s*([^\n]+?)\s*\n/ matches any text after “print time:”, on the same line, ignoring surrounding whitespace
\s*, and saves it as the first capture group using the
 selects the contents of that first capture group.
After extracting the
print_time string, you can do whatever you need to with it. For example, if you had a Rails model
PrintTime, you might save the extracted time to the database with