See if this does the trick for you. It returns an array.
<cffunction name="seperateToArray" returntype="array">
<cfargument name="myString" required="yes" type="string">
<cfargument name="maxLength" required="yes" type="numeric">
<cfset var myArray = arrayNew(1)>
<cfset var spcPos = 0>
<cfset var myTmpStr = "">
<cfset var myTmpAry = false>
<cfif len(myString) GT maxLength>
<cfset spcPos = maxLength - len(listLast(left(myString, maxLength), " "))>
<cfset myTmpStr = left(myString, spcPos)>
<cfset myArray = seperateToArray(right(myString, len(myString) - spcPos),
maxLength)>
<cfelse>
<cfset myTmpStr = myString>
</cfif>
<cfset myTmpAry = arrayPrepend(myArray, myTmpStr)>
<cfreturn myArray>
</cffunction>
Steve
-----Original Message-----
From: Ian Skinner [mailto:[EMAIL PROTECTED]
Sent: Monday, December 01, 2003 1:32 PM
To: CF-Talk
Subject: RE: The Last Space.
I hadn't thought of this approach, I see merit here, I'll look into it.
--------------
Ian Skinner
Web Programmer
BloodSource
www.BloodSource.org
Sacramento, CA
-----Original Message-----
From: C. Hatton Humphrey [mailto:[EMAIL PROTECTED]
Sent: Monday, December 01, 2003 10:13 AM
To: CF-Talk
Subject: RE: The Last Space.
I'm sure there's more than one way to solve this particular issue, my
thought would be to turn the string into a list using the space as a
delimiter, then add the length of the list element plus one (for the
space) until you reach or break your cutoff level.
Not very pretty but it'd get the job done.
Hatton
-----Original Message-----
From: Ian Skinner [mailto:[EMAIL PROTECTED]
Sent: Monday, December 01, 2003 1:03 PM
To: CF-Talk
Subject: The Last Space.
Anybody know a trick (regex or otherwise) to find the position of the
last
white space character before an arbitrary limit?
In the following example, I want the position of the last white space
before
the 25th character.
"The quick brown fox jumped over a lazy dog."
So I would want the position of the white space after 'fox', which is
the
20th character. This is the last white space before the 25th character
with
is the 'e' in 'jumped'. Allowing me to break the string into:
"The quick brown fox " <!-- note: trailing white space is included.
-->
"jumped over a lazy dog."
I don't think this should be that hard, but for some reason, it has
given me
lots of trouble.
Thanks
--------------
Ian Skinner
Web Programmer
BloodSource
www.BloodSource.org
Sacramento, CA
Confidentiality Notice: This message including any
attachments is for the sole use of the intended
recipient(s) and may contain confidential and privileged
information. Any unauthorized review, use, disclosure or
distribution is prohibited. If you are not the
intended recipient, please contact the sender and
delete any copies of this message.
_____
[HYPERLINK "http://www.houseoffusion.com/lists.cfm?link=t:4"Todays
Threads] [HYPERLINK
"http://www.houseoffusion.com/lists.cfm?link=i:4:145544"This Message]
[HYPERLINK
"http://www.houseoffusion.com/lists.cfm?link=s:4"Subscription]
[HYPERLINK
"http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=2581.2460.4"
Fast Unsubscribe] [HYPERLINK "http://www.houseoffusion.com/signin/"User
Settings]
_____
HYPERLINK "http://www.houseoffusion.com/banners/view.cfm?bannerid=17" \n
---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.543 / Virus Database: 337 - Release Date: 11/21/2003
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.543 / Virus Database: 337 - Release Date: 11/21/2003
_____
_____
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

