convert reg to ruby