我有什么方法可以在AppleScript Obj-C中使用下面的方法或类似的方法吗?
NSString *request = [urlString stringByReplacingOccurrencesOfString:@"{query}"
withString:queryString];
答案 0 :(得分:0)
您可以使用文字项分隔符
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-----"
答案 1 :(得分:0)
这是有效的代码:
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
答案 2 :(得分:0)
要回答问题的第一部分,您可以转换Cocoa方法并使用等效的ASOC语句(请参阅AppleScriptObjC Release Notes):
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