Re. Search for a character
Re. Search for a character
- Subject: Re. Search for a character
- From: email@hidden
- Date: Tue, 20 Sep 2005 13:59:45 +0200
> Timothy K. Wilkinson wrote:
> I just need a line that says "give me every word in this line that
contains a %".
> Anyone know the syntax I would need?
If you really want to use text item delimiters, one solution would be:
set testText to "This is line 1" & return & "Th%is is li%ne 2" & return &
"This is line 3"
set hitList to FindPercentageSign(testText)
--> {"Th%is", "li%ne"}
on FindPercentageSign(inputString)
set {oldTID, AppleScript's text item delimiters} to {AppleScript's text
item delimiters, return}
set hitLine to (text item 2 of inputString)
set AppleScript's text item delimiters to {space}
set hitWords to text items of hitLine
set hitLength to length of hitWords
set hitList to {}
set AppleScript's text item delimiters to {"%"}
repeat with i from 1 to hitLength
set candidate to (item i of hitWords)
if (length of (text items of candidate)) > 1 then
set end of hitList to candidate
end if
end repeat
set AppleScript's text item delimiters to oldTID
return hitList
end FindPercentageSign
mws
This message and any attachment are confidential and may be privileged or
otherwise protected from disclosure. If you are not the intended recipient,
you must not copy this message or attachment or disclose the contents to
any other person. If you have received this transmission in error, please
notify the sender immediately and delete the message and any attachment
from your system. Merck does not accept liability for any omissions or
errors in this message which may arise as a result of E-Mail-transmission
or for damages resulting from any unauthorized changes of the content of
this message and any attachment thereto. Merck does not guarantee that this
message is free of viruses and does not accept liability for any damages
caused by any virus transmitted therewith.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden