-
do shell script
を使わないとできなかった正規表現の文字列置き換え - AppleScript上でCocoaの機能を使えるようになった
regexReplace.scpt
use framework "Foundation"
my regexReplace("<p>あいうえお</p>", "<.+?>", "")
--> "あいうえお"
on regexReplace(aText as text, pattern as text, replacement as text)
--require framework: Foundation
set regularExpression to current application's NSRegularExpression's regularExpressionWithPattern:pattern options:0 |error|:(missing value)
return (regularExpression's stringByReplacingMatchesInString:aText options:0 range:{location:0, |length|:count aText} withTemplate:replacement) as text
end regexReplace
更新履歴
- 2016-01-07: Cocoaの機能を使って作成