Try something like this.  It's easier to write than to explain :)



<cfset myString="The quick brown fox jumped over the lazy dog.">
<cfset n = 30>

<cfif not mid(myString,n,1) eq " ">
        <cfset n = find(" ",myString,n)>
</cfif>

<cfset myString = left(myString,n)>

<cfoutput>#myString#</cfoutput>





Good Luck!

Eric


-----Original Message-----
From: Ian Lurie [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, May 29, 2002 11:30 AM
To: CF-Talk
Subject: RegEx or something else?


If I am outputting the first n characters of a string to a page, like this:

The quick brown fox jumped over...

And I want to make sure I never get this:

The quick brown fox jumped o....

Would I used RegEx? Or something else? What's the easiest way to make sure
that that last bit of the string displayed is a whole word?

Thanks,

Ian

Portent Interactive
Helping clients build customer relationships on the web since 1995
Consulting, design, development, measurement
http://www.portentinteractive.com
Talk with us: http://projects.portentinteractive.com


______________________________________________________________________
Get the mailserver that powers this list at http://www.coolfusion.com
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to