• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Reformatting a string
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reformatting a string


  • Subject: Re: Reformatting a string
  • From: KOENIG Yvan <email@hidden>
  • Date: Fri, 27 Jan 2012 20:27:57 +0100


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



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Reformatting a string (From: Angelo <email@hidden>)

  • Prev by Date: Re: Reformatting a string
  • Next by Date: Re: Reformatting a string
  • Previous by thread: Re: Reformatting a string
  • Next by thread: Re: Reformatting a string
  • Index(es):
    • Date
    • Thread