fork download
  1. ll <- readLines(textConnection("(412) 573-7777 opt 1
  2. 563.785.1655 x1797
  3. (567) 523-1534 x7753
  4. (567) 483-2119 x 477
  5. (451) 897-MALL
  6. (342) 668-6255 ext 7
  7. (317) 737-3377 Opt 4
  8. (239) 572-8878 x 3
  9. 233.785.1655 x1776
  10. (138) 761-6877 x 4
  11. (411) 446-6626 x 14
  12. (412) 337-3332x19
  13. 412.393.3177 x24
  14. 327.961.1757 ext.4"))
  15. gsub('[(]?([0-9]{3})[)]?[. -]([A-Z0-9]{3})[. -]([A-Z0-9]{4}).*','\\1-\\2-\\3',ll)
Success #stdin #stdout 0.3s 22840KB
stdin
Standard input is empty
stdout
 [1] "412-573-7777" "563-785-1655" "567-523-1534" "567-483-2119" "451-897-MALL"
 [6] "342-668-6255" "317-737-3377" "239-572-8878" "233-785-1655" "138-761-6877"
[11] "411-446-6626" "412-337-3332" "412-393-3177" "327-961-1757"