AppleScript名:1D Listから条件抽出(正規表現2) |
— Created 2017-11-03 by Takaaki Naganoya — 2017 Piyomaru Software use AppleScript version "2.4" use scripting additions use framework "Foundation" –http://piyocast.com/as/archives/4949 property NSPredicate : a reference to current application’s NSPredicate property NSArray : a reference to current application’s NSArray set aList to {"123456789X", "9876x", "987654321x", "1234567890", "12345X", "1234567890X", "999999999X", "1111111111", "222222222X"} set anArray to NSArray’s arrayWithArray:aList set aPred to NSPredicate’s predicateWithFormat:"SELF MATCHES ’\\\\d{10}|\\\\d{9}[Xx]’" set bRes to (anArray’s filteredArrayUsingPredicate:aPred) as list –> {"123456789X", "987654321x", "1234567890", "999999999X", "1111111111", "222222222X"} |
More from my site
(Visited 20 times, 1 visits today)