Weeding out words
Weeding out words
- Subject: Weeding out words
- From: Brett Conlon <email@hidden>
- Date: Thu, 8 Feb 2007 16:38:39 +1000
Hi all,
I have written a "cleanup"
handler to search for words within the text returned in a user dialog.
However, it is stripping too much and I'm looking for assistance to help
me clean up my cleanup. ;-D
Here's what I've written so far:
set
TitleAns to
"My Collection box set asset boxy dog box collection is here"
-- some example text returned in a user dialog
set
Offenders to
{"collection", "box", "set", "boxset"}
-- words which need to be stripped if the user entered them by mistake.
repeat
5 times
--5 times stops endless repeating if any below offending words aren't
separated by a space
set
storedDelimiters to
AppleScript's text item delimiters
set
OffenderItems to
Offenders's items
repeat
with
i in
OffenderItems
if
TitleAns contains
i then
set
i to
(" " & i)
set
AppleScript's text item delimiters to
i
set
TitleAns to
TitleAns's text items
set
AppleScript's text item delimiters to
""
set
TitleAns to
TitleAns as
Unicode text
set
AppleScript's text item delimiters to
storedDelimiters
else
exit
repeat
end
if
end
repeat
end
repeat
log TitleAns
result: (*My
assety dog is here*)
I guess because I'm using text item
delimiters to isolate offending words it is finding them inside other words
and messing up those that are supposed to be there.
Your help is most appreciated!
Cheers,
Coj _______________________________________________
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/mailman//archives/applescript-users
This email sent to email@hidden