Convert Phone Number to XXX-XXX-XXXX Format

I take the point. I think that it is useful when examples that folk post and I know that is up to them, include, as you do, the actual name of the variable they are using as it were rather than a generic? Like you did above. It was very helpful though it might seem a minor detail.

You would if there was a label just above the door knob that said "Turn door knob to open door".

In many Apps, including parts of KM, there is such a label -- it is the unselectable text shown in grey in the text box, like this:

image

although I would have used "Enter search terms here"

1 Like

Both you and Peter make good points. What we can do for the time being is make sure if we upload an example that it is done like Peter does and show the actual variable name that was used in that specific macro? I think that is his way of doing it mostly, if I remember right. I still think Variables deserve a Sparks instruction course of their own. Or by somebody else who understands them well.

I came here looking for a solution for a similar problem. I found the solution with asking ChatGPT to create a RegEx I can use with KM.

Input:

17736532787

Output:

+1 (773) 653-2787

In ChatGPT I give it the prompt…

create regex to format 17736532787 as a phone number so it outputs +1 (773) 653-2787

ChatGPT responded with

Add a "Search and Replace" action and set the search pattern to ^(\d{1})(\d{3})(\d{3})(\d{4})$ and the replace pattern to +1 ($2) $3-$4

In KM it looks like this.

Do note that it has assumed you always want to replace the first digit of your number, whatever it is, with a 1. Only you know if that's correct...

2 Likes