Apple - Removing all characters except digits from clipboard
The shell snippet
pbpaste | tr -cd "[:digit:]+" | pbcopy
will take the content of the clipboard, remove all non-digits and put the result back into the clipboard.
An AppleScript solution:
set the clipboard to the words of (the clipboard) as text