[thelist] Re: ASP: First 100 words in a record

William Kolean williamkolean at mac.com
Wed Jun 19 18:52:01 CDT 2002


You could search for the first space after a certain number of characters by
specifying a start position, for example
    synopsisEndPos = inStr(100, articleBody, " ")

And then trim from there
    synopsis = trim(left(articleBody, synopsisEndPos))

The tricky part is dealing with trailing commas, periods, etc. You could
also search for the first ". " from a certain point and get a complete
sentence, but of course if your writers like run-on sentences you might have
a bit of trouble getting a synopsis that's much smaller than the full
article.

William

>> the synopsis used to be the first x characters of the article.
>
> After a bit of reflection, the first x characters might just be a better way
> of doing this, rather than the first x words. Doesn't help that it's a LOT
> easier to do, of course... :)
>
>> if you want 100 words instead, i can't see any other way than:
>
>> split() the string on a space
>> keep only first 100 array items
>> join() with a space
>
>> but i'd think this is a nightmere as far as resources go.
>
> Which is exactly why I posted to the list - I couldn't see any way around
> it.
>
> Thanks!
>
> -Ken




More information about the thelist mailing list