Hi all,
I’m trying to turn this text:
Sample Text (More Sample Text)
into this:
Sample text (More sample text)
Basically, I need to have the beginning of the string and the beginning INSIDE the parentheses to be sentence cased.
I’m tryin using a existing TID script I have, but I’m not getting very far.
property theLowerAlphabet : "abcdefghijklmnopqrstuvwxyzà à èìòùáéÃóúâêîôûãñõäëïöüÿæåçøœ1234567890"
property theUpperAlphabet : "ABCDEFGHIJKLMNOPQRSTUVWXYZÀÀÈÌÒÙÃÉÃÓÚÂÊÎÔÛÃÑÕÄËÃÖÜŸÆÅÇØŒ1234567890"
property whiteSpace : {space, tab, return, ASCII character 10, ASCII character 13, ASCII character 40}
set theOriginalText to the clipboard
setTID("(")
set textInside to (text item 2 of theOriginalText) as string
setTID(")")
set textInside to (text item 1 of textInside) as string
setTID("")
setTID("(")
set textOutside to (text item 1 of theOriginalText) as string
to setTID(newTID)
set AppleScript's text item delimiters to {newTID}
end setTID
set textInside to the clipboard
get change_case(textOutside, textInside, "Sentence")
on change_case(this_text, this_case)
set new_text to ""
if this_case is not in {"UPPER", "lower", "Title", "Sentence"} then
return "Error: Case must be UPPER, lower, Title or Sentence"
end if
if this_case is "lower" then
set use_capital to false
else
set use_capital to true
end if
repeat with this_char in this_text
set x to offset of this_char in theLowerAlphabet
if x is not 0 then
if use_capital then
set new_text to new_text & character x of theUpperAlphabet as string
if this_case is not "UPPER" then
set use_capital to false
end if
else
set new_text to new_text & character x of theLowerAlphabet as string
end if
else
if this_case is "Title" and this_char is in whiteSpace then
set use_capital to true
end if
set new_text to new_text & this_char as string
end if
end repeat
-- set the clipboard to new_text
-- return new_text
end change_case
--set theInput to the clipboard
return textOutside & "(" & textInside & ")"
Any help would be greatly appreciated!
Thanks in advance and happy holidays!
Browser: Safari 525.26.12
Operating System: Mac OS X (10.5)