Le 27 janv. 2012 à 19:07, Angelo a écrit :
I need to take a long string string of letters numbers and colons and convert it to uppercase letters w/ no colons. a2:fh:2f:vv:i1:q1 needs to be A2FH2FVVI1Q1. (the string is normally longer that this example)
I currently slap it into a new Mail document and “Transform” to uppercase and then “Find” the colons and replace with nothing. That works OK, but I know it’s archaic and one of you guys could craft a script in a few minutes that would take me a few hours to create. I was thinking along the lines of a dialog box where I pasted the raw string and it produced a message box with the reformatted version, but anything would be helpful. Is it possible to copy the string and then do the reformatting to the contents of the Clipboard so that I can just copy -> run script -> paste where it needs to go?
Thanks! Angelo
Here is a better one : --=====
my changeCase(the clipboard as text, "upper") set the clipboard to my supprime(result, ":")
--===== (* removes every occurences of d in text t *) on supprime(t, d) local oTIDs, l set oTIDs to AppleScript's text item delimiters set AppleScript's text item delimiters to d set l to text items of t set AppleScript's text item delimiters to "" set t to l as text set AppleScript's text item delimiters to oTIDs return t end supprime
--===== (* Le second argument peut être: "upper", "lower", "title", "capitalize" *)
on changeCase(txt, mode) set python_script to "import sys; print sys.argv[1].decode('utf8')." & mode & "().encode('utf8')" return do shell script "/usr/bin/python -c " & quoted form of python_script & " " & quoted form of txt end changeCase
--=====
Yvan KOENIG (VALLAURIS, France) vendredi 27 janvier 2012 20:27:03
|