Re: Simple text question
Re: Simple text question
- Subject: Re: Simple text question
- From: "Mark J. Reed" <email@hidden>
- Date: Mon, 7 Jul 2008 17:02:09 -0400
On Mon, Jul 7, 2008 at 4:57 PM, Michelle Steiner <email@hidden> wrote:
> On Jul 7, 2008, at 1:54 PM, Mark J. Reed wrote:
>
>> There's always brute force:
>
> But what if the last character of the gibberish is a number?
True, he did say "1 to 4 digits", not "1 or more digits". They rhyme,
but they are distinct...
this should work:
set a to "gibberish 123430[Foobazoo]this is test (#1)."
set last_digit to 0
set final to offset of "]" in a
if final is not 0 then
set initial to final - 1
repeat while initial > 1 and text initial of a is not "["
set initial to initial - 1
end repeat
if text initial of a is "[" then
repeat while initial > 1
set ch to text (initial - 1) of a
if ch >= "0" and ch <= "9" then
if last_digit is 0 then
set last_digit to initial
else if (last_digit - initial) is 4 then
exit repeat
end if
set initial to initial - 1
else
exit repeat
end if
end repeat
end if
if last_digit is not 0 then
return text initial through final of a
end if
end if
return the missing value
--
Mark J. Reed <email@hidden>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden