• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re. Search for a character
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Re. Search for a character
      • From: "Gary (Lists)" <email@hidden>
  • Prev by Date: Re: How to save a QuickTime 7 reference movie?
  • Next by Date: Re: How to deal with Asynchronous Finder operations
  • Previous by thread: Re: Getting info back from iCal: missing values ?
  • Next by thread: Re: Re. Search for a character
  • Index(es):
    • Date
    • Thread