Re: Name rearrangement
Re: Name rearrangement
- Subject: Re: Name rearrangement
- From: Christopher Stone <email@hidden>
- Date: Tue, 30 Mar 2004 04:25:24 -0600
On Mar 30, 2004, at 2:04 AM, Jim Witte wrote:
What's a script that will take a name in the form of "STOOGE, CURLY"
and turn it into "Curly Stooge" This would be an absolute cinch in PHP
or Perl - but I'd rather not have to be calling out to the Terminal to
execute a Perl one-liner every time I want to do this..
----------------------------------------------------------------------
-- Vanilla AppleScript
set theName to "STOOGE, CURLY"
set AppleScript's text item delimiters to {" "}
set theName2 to reverse of ({word 1, word 2} of theName) as string
set AppleScript's text item delimiters to {""}
theName2
-- Using the Satimage osax
set useRegEx to change "(\\w+), (\\w+)" into "\\2 \\1" in theName with
regexp without case sensitive
-- Use Satimage osax to form title case
set useRegEx to words of (lowercase useRegEx)
repeat with i in useRegEx
set contents of i to (uppercase (character 1 of i)) & (text 2 thru -1 of i)
end repeat
set AppleScript's text item delimiters to {" "}
set useRegEx to useRegEx as string
set AppleScript's text item delimiters to {""}
useRegEx
----------------------------------------------------------------------
I've wished for some time that the Satimage osax would do title-case and
sentence-case, but alas...
The Satimage osax:
http://www.satimage.fr/software/en/downloads_osaxen.html
The old RegEx Commands osax for Mac OS 9 would do case conversion, and
some other things I miss on Mac OS X.
Personally I use the ACME Script Widgets osax to do case conversions, but
it's commercial ($29.00).
<
http://www.acmetech.com/index.php?module=pagemaster&PAGE_user_op=view_page&PAGE_id=7&MMN_position=21:12>
Chris
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.