Re: getting chunks of text
Re: getting chunks of text
- Subject: Re: getting chunks of text
- From: Christian Vinaa <email@hidden>
- Date: Fri, 25 Mar 2005 14:51:55 +0100
At 19:40 -0800 16/03/2005, Scott Haneda wrote:
Given a string of length unknown, I need to chop it up to less than 256
characters, however, I do not want to chop a word in half, so scan backwards
to the first space before 256 chars. Not to worried about what would happen
when running into punctuation and such.
I need a result set that I can repeat through, thanks.
--
-------------------------------------------------------------
Scott Haneda Tel: 415.898.2602
<http://www.newgeo.com> Novato, CA U.S.A.
a bit late in reply but how about this:
set theText to "Mae seryddwyr yn dweud eu bod wedi canfod beth maent yn
credu yw galaeth anweledig newydd. Mae'r tîm, sy'n cael eu harwain gan
Brifysgol Caerdydd, yn honni mai dyma'r cyntaf i'w chanfod sydd wedi ei
wneud o fater tywyll. Ardal o fewn y bydysawd yn cynnwys cyfanswm mawr o
fás sy'n troi fel galaeth ond nad yw'n cynnwys sêr yw galaeth dywyll.
Cafodd ei darganfod 50 miliwn o flynyddoedd goleuni i ffwrdd drwy
ddefnyddio telesgopau radio yn Sir Gaer a Puerto Rico."
set text1 to characters 1 through 256 of theText as text
set lastWordNumber to count of words in text1
set textWordA to word lastWordNumber of theText
set textWordB to word lastWordNumber of text1
if textWordA = textWordB then
set myFinalText to words 1 through lastWordNumber of theText
else
set myFinalText to words 1 through (lastWordNumber - 1) of theText
end if
( and I have no doubt that Kai can do a oneliner ! )
--
Christian Vinaa
...... Meanwhile, aunt Martha, having taken a tramp in the woods,
is lying in a ditch at the edge of town .........................
_______________________________________________
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