Characterizing local rings via homological dimensions and regular sequences