Format Phone Number in Table

How can you format a phone number in a table to look like a phone number? ex

Hey @nroeder,

I usually introduce a simpleton global function like this

window.phoneFormat = function(input){
  input = _.replace(input, new RegExp("\D","g"),"qu")
  var size = input.length;
  if (size>0) {input="("+input}
  if (size>3) {input=input.slice(0,4)+") "+input.slice(4,11)}
  if (size>6) {input=input.slice(0,9)+"-" +input.slice(9)}
  return input;

Used as {{phoneFormat(self)}} in the row you want to parse.

You could expand this a bit and add some fail checks but it works 95% of the time in my use-case

Thanks man, been struggling with that for awhile.

1 Like

Hey! Wanted to update this thread to let you all know we just launched a phone number column type on Table!

You can check out the anouncement here: New: Phone number column type on Table.

1 Like