I need a method to return a string in the phone number format "\(XXX\) - xxx - xxxx" where the input value is a string of 10 characters. The "\(" and the "\)" are required as the output string is embedded in a PDF file in a draw text command of Td().
My tried methods are as follows
func formatPhone(theData: String)
{
return "\(\( \(theData[0...2])\) - \(theData[3...5]) - \(theData[6...9]))"
}
I have also tried
func formatPhone(theData: String)
{
return "\("+"\(theData[0...2])+"\) ) - \(theData[3...5]) - \(theData[6...9]))"
}
I have also tried
func formatPhone(theData: String)
{
return "\("+theData[0...2]+"\) - "+theData[3...5]"+" - "+theData[6...9]
}
I have not found a way to include the "\(" or the "\)" in the formatted output as the gravity compiler thinks there is an error as "\(" or the next ")" have a special meaning when compiling. Any ideas how to do this would be most appreciated. It is probably simpler than I make it out to be!
Thanks for your time in advance.