Стандарт от Philips Medical Systems правильно написан, и главным образом следует инструкциям Microsoft: www.tiobe.com/content/paperinfo/gemrcsharpcs.pdf
Мои стандарты основаны на этом с несколькими тонкими настройками, и некоторые обновления для.NET 2.0 (стандарт Philips записан для.NET 1.x, так немного датирован).
set s to "Today is my birthday"
set AppleScript's text item delimiters to "my"
text item 1 of s
--> "Today is "
Возможно, немного неуклюже, но он выполняет свою работу ...
property kSourceText : "Today is my birthday"
property kStopText : "my"
set newSubstring to SubstringUpToString(kSourceText, kStopText)
return newSubstring -- "Today is "
on SubstringUpToString(theString, subString) -- (theString as string, subString as string) as string
if theString does not contain subString then
return theString
end if
set theReturnString to ""
set stringCharacterCount to (get count of characters in theString)
set substringCharacterCount to (get count of characters in subString)
set lastCharacter to stringCharacterCount - substringCharacterCount
repeat with thisChar from 1 to lastCharacter
set startChar to thisChar
set endChar to (thisChar + substringCharacterCount) - 1
set currentSubstring to (get characters startChar thru endChar of theString) as string
if currentSubstring is subString then
return (get characters 1 thru (thisChar - 1) of theString) as string
end if
end repeat
return theString
end SubstringUpToString