Re: Reformatting a string
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)
|
_______________________________________________
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