AppleScript名:指定のMarkdown書類を走査して指定文字列(Question)をカウント |
— Created 2017-11-14 by Takaaki Naganoya — 2017 Piyomaru Software use AppleScript version "2.4" use scripting additions use framework "Foundation" set origPath to (choose file of type {"net.daringfireball.markdown"} with prompt "処理対象のMarkdown書類を選択") set aText to (read origPath as «class utf8») set aFreq to retFrequency(aText, ">Q") of me –指定文字列内の指定キーワードの出現回数を取得する on retFrequency(origText, aKeyText) set aRes to parseByDelim(origText, aKeyText) of me return ((count every item of aRes) – 1) end retFrequency on parseByDelim(aData, aDelim) set curDelim to AppleScript’s text item delimiters set AppleScript’s text item delimiters to aDelim set dList to text items of aData set AppleScript’s text item delimiters to curDelim return dList end parseByDelim |
More from my site
(Visited 43 times, 1 visits today)