有什么方法可以在 AppleScript Obj-C 中使用下面的方法或类似的方法?
NSString *request = [urlString stringByReplacingOccurrencesOfString:@"{query}"
withString:queryString];
有什么方法可以在 AppleScript Obj-C 中使用下面的方法或类似的方法?
NSString *request = [urlString stringByReplacingOccurrencesOfString:@"{query}"
withString:queryString];
您可以使用文本项目分隔符
set theReplacementString to "-----"
set {theOriginal, text item delimiters} to {text item delimiters, "{query}"}
set theParts to every text item of "{query}asd{query}sadsa{query}"
set text item delimiters to theReplacementString
set theResult to theParts as string
set text item delimiters to theOriginal
return theResult
给你
"-----asd-----sadsa-----"
要回答您问题的第一部分,您可以转换 Cocoa 方法并使用等效的 ASOC 语句(请参阅AppleScriptObjC 发行说明):
set urlString to current application's NSString's stringWithString_("{query}asd{query}sadsa{query}") -- create an NSString to use with the Cocoa method
set queryString to "-----" -- the replacement string
set request to urlString's stringByReplacingOccurrencesOfString_withString_("{query}", queryString) -- the NSString method in ASOC
display dialog request as text
这是有效的代码:
set theText to "01 01 2005"
set AppleScript's text item delimiters to " "
set theTextItems to text items of theText
set AppleScript's text item delimiters to "/ "
set theText to theTextItems as string
set AppleScript's text item delimiters to {""}
theText