• 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: Removing characters from a string
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Removing characters from a string


  • Subject: Re: Removing characters from a string
  • From: Kai Edwards <email@hidden>
  • Date: Tue, 29 Oct 2002 11:56:52 +0000

on 29/10/02 10:02 am, I wrote:

> - or you could do most of it with TIDs, looping through the illegal characters
> instead:
>
> ---------------------------------------------------
> set l to {".", ",", "/", ":"}
> set n to "this/might not.be a legal:name, then again, it could be."
> set tid to text item delimiters
> repeat with i from 1 to count l
> set text item delimiters to l's item i
> set n to (n as string)'s text items
> end repeat
> set text item delimiters to tid
> set n to n as string
> if n's length > 32 then set n to n's text 1 thru 32
> n
> ---------------------------------------------------

- or better still, this shaves a whisker off the length and time:

---------------------------------------------------
set tid to text item delimiters
set l to {".", ",", "/", ":", tid}
set n to "this/might not.be a legal:name, then again, it could be."
set text item delimiters to l's item 1
repeat with i from 2 to count l
set {n, text item delimiters} to {(n as string)'s text items, l's item i}
end repeat
set n to n as string
if n's length > 32 then set n to n's text 1 thru 32
n
---------------------------------------------------

Kai

--
email@hidden
email@hidden
_______________________________________________
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.

  • Follow-Ups:
    • Re: Removing characters from a string
      • From: Paul Skinner <email@hidden>
  • Prev by Date: Re: using non-ascii chars on this mailing list
  • Next by Date: Re: Removing characters from a string
  • Previous by thread: Re: Removing characters from a string
  • Next by thread: Re: Removing characters from a string
  • Index(es):
    • Date
    • Thread