So, I needed a quick way to format several phone numbers in a series of web fields where import/export wasn’t really a viable option.

One of the great things about OS X and it’s Unix-y underpinnings is that I was able to cobble together a single command line like this to run a regex right on the clipboard contents… Basically pull it in, pipe it through sed, and then push it back onto the clipboard.

'pbpaste | sed e ‘s/[\+1( -.]*\([0-9][0-9][0-9]\)[) -.]*\([0-9][0-9][0-9]\)[ .]*\([0-9][0-9][0-9][0-9]\)/+1 (\1) \2-\3/’ | pbcopy

So CMD+A/CMD+C, run script, CMD+V, done.