• 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: Thomas Fischer <email@hidden>
  • Date: Sat, 28 Jan 2012 10:43:57 +0100

Hi,

if I have to add additional software, I'd rather stick with AppleScript and take the (always useful) Satimage.osax with its "change" and regular expressions. This worked correctly for all characters I checked (up to character id 255).
With this, the task looks like this:

on run
set the clipboard to my transformedText(get the clipboard)
end run

on transformedText(theText)
set theText to change ":" into "" in theText
return change "(.*)" into "\\u$1" in theText with regexp
end transformedText

Best
Thomas


Am 27.01.2012 um 23:42 schrieb Shane Stanley:

On 28/01/2012, at 8:02 AM, KOENIG Yvan wrote:

Just that when I don't know the exact contents of strings to treat, I choose the code supposed to be able to treat every case.
Old habit of an inhabitant of a country using several non ASCII characters.

A good thing too. 

In the interests of variety, speed and, dare I prompt an argument, legibility, here's another version:

script capNStuff
set x to current application's NSApp's convertedValue()
set x to x's componentsSeparatedByString_(":")
set x to x's componentsJoinedByString_("")
set x to x's uppercaseString()
end script

set the clipboard to "a2:fh:2f:vv:i1:q1:For:Yvan:KÅ’NIG"
tell application "ASObjC Runner" to set the clipboard to (run the script {capNStuff} converting (get the clipboard as text) with result returned)

-- 
Shane Stanley <email@hidden>
'AppleScriptObjC Explored' <www.macosxautomation.com/applescript/apps/>
 _______________________________________________
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

  • Follow-Ups:
    • Re: Reformatting a string
      • From: Shane Stanley <email@hidden>
References: 
 >Reformatting a string (From: Angelo <email@hidden>)
 >Re: Reformatting a string (From: Michelle Steiner <email@hidden>)
 >Re: Reformatting a string (From: KOENIG Yvan <email@hidden>)
 >Re: Reformatting a string (From: Shane Stanley <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