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
I have an alternative, until I have implemented the character class for the Thompson NFA Algorithm I have made the bare bones of work in AppleScript. If someones interested in looking for parsing very basic regex's with Applescript, then code is posted in CodeExchange at MacScripters, please have a look!
Here is the solution for figuring out if the ten first characters of a text/string:
set mstr to "1234567889Abcdefg"
set isnum to prefixIsOnlyDigits for mstr
to prefixIsOnlyDigits for aText
set aProbe to text 1 thru 10 of aText
set isnum to false
if not ((offset of "," in aProbe) > 0 or (offset of "." in aProbe) > 0 or (offset of "-" in aProbe) > 0) then
try
set aNumber to aProbe as number
set isnum to true
end try
end if
return isnum
end prefixIsOnlyDigits