1 refers to the match of the first group : Regexps Group Development Ruby

#  the second group,and so on.

# Outside the pattern,the special variables $1, $2, and so on, serve the samepurpose. 

"12:50am" =~ /(dd):(dd)(..)/ # 0 
"Hour is #$1, minute #$2" # "Hour is 12, minute 50" 
"12:50am" =~ /((dd):(dd))(..)/ # 0 
"Time is #$1" # "Time is 12:50" 
"Hour is #$2, minute #$3" # "Hour is 12, minute 50" 
"AM/PM is #$4" # "AM/PM is am"