If I have an international phone number such as this:
0541754301
how can I format it to produce something like this:
You can use regular expression to reformat the string. For the example you have given:
"0541754301".sub(/(\d{4})(\d{3})(\d{3})/, "\\1-\\2-\\3") # returns: "0541-754-301"