is there something akin to regEx in applescript, and if not, what's the alternative?

前端 未结 7 709
感动是毒
感动是毒 2020-12-04 15:54

I need to parse the first 10 chars of a file name to see if they are all digits. The obvious way to do this is fileName =~ m/^\\d{10}/ but I\'m not seeing anything regExy i

7条回答
  •  一向
    一向 (楼主)
    2020-12-04 16:16

    I recently had need of regular expressions in a script, and wanted to find a scripting addition to handle it, so it would be easier to read what was going on. I found Satimage.osax, which lets you use syntax like below:

    find text "n(.*)" in "to be or not to be" with regexp
    

    The only downside is that (as of 11/08/2010) it's a 32-bit addition, so it throws errors when it's called from a 64-bit process. This bit me in a Mail rule for Snow Leopard, as I had to run Mail in 32-bit mode. Called from a standalone script, though, I have no reservations - it's really great, and lets you pick whatever regex syntax you want, and use back-references.

    Update 5/28/2011

    Thanks to Mitchell Model's comment below for pointing out they have updated it to be 64-bit, so no more reservations - it does everything I need.

提交回复
热议问题