'booga' =~ /[^.]*/ matches. 'booga.' =~ /[^.]*/ matches. 'booga' =~ /(?=.*\.)/ does not match. 'booga.' =~ /(?=.*\.)/ matches. '4.6.8' =~ /[^.]*\.(\d)/ returns 6 in $1. '4.6.8' =~ /(?=.*\.)(\d)/ returns 4 in $1. '4.6.8' =~ /((?=.*\.))\1(\d)/ returns 8 in $2. .* matched a "4.6" '4.6.8' =~ /.*\.(\d)/ returns 8 in $1. Lookahead not needed. '4.6.8' =~ /(?:(?!\.).)*(\d)/ returns 6 in $1. You want neg lookahead