AppleScript名:&と=で区切られたテキストをrecordに 改 |
— Created 2016-12-12 by Shane Stanley — Modified 2016-12-14 by edama2 use AppleScript version "2.4" use scripting additions use framework "Foundation" –http://piyocast.com/as/archives/4358 set aParamStr to "access_token=XXxxx(XXxXXXXXxxXxxXXx))&expires=86399&name=" set aDict to (parseStrByAmpAndEqual(aParamStr) of me) –> {expires:"86399", |name|:"", access_token:"XXxxx(XXxXXXXXxxXxxXXx))"} on parseStrByAmpAndEqual(aParamStr) set theScanner to current application’s NSScanner’s scannerWithString:aParamStr set aDict to current application’s NSMutableDictionary’s |dictionary|() repeat until (theScanner’s isAtEnd as boolean) — terminate check, return the result (aDict) to caller set {theResult, theKey} to theScanner’s scanUpToString:"=" intoString:(reference) — skip over separator theScanner’s scanString:"=" intoString:(missing value) set {theResult, theValue} to theScanner’s scanUpToString:"&" intoString:(reference) if theValue is missing value then set theValue to "" –>追加 — skip over separator theScanner’s scanString:"&" intoString:(missing value) aDict’s setObject:theValue forKey:theKey end repeat return aDict as record end parseStrByAmpAndEqual |
More from my site
(Visited 13 times, 1 visits today)