limiting numeric runs
limiting numeric runs
- Subject: limiting numeric runs
- From: Paul Skinner <email@hidden>
- Date: Wed, 8 Jan 2003 12:47:54 -0500
I need to limit the length of numeric runs in a given text. Does anyone
have a suggestion as to a non-looping solution?
This is too slow.
LimitNumericRuns("676798697675785", 4)
-->"6767"
on LimitNumericRuns(inputText, runLengthLimit)
set inputText to characters of inputText
set numeralRun to 0
repeat with i from 1 to length of inputText
set thisw to item i of inputText
if thisw is in {"1", "2", "3", "4", "5", "6", "7", "8", "9", "0"} then
set numeralRun to numeralRun + 1
if numeralRun > runLengthLimit then set item i of inputText to ""
else
set numeralRun to 0
end if
end repeat
set AppleScript's text item delimiters to ""
return inputText as string
end LimitNumericRuns
--
Paul Skinner
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.