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

前端 未结 7 701
感动是毒
感动是毒 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:36

    Here's another way to check if first ten characters of any string are digits.

        on checkFilename(thisName)
            set {n, isOk} to {length of fileName, true}
            try
                repeat with i from 1 to 10
                    set isOk to (isOk and ((character i of thisName) is in "0123456789"))
                end repeat
                return isOk
            on error
                return false
            end try
        end checkFilename
    
    0 讨论(0)
提交回复
热议问题