You could strip out the first 25 characters and do a reverse on the
resulting string and then just do a find for the first space.  Then subtract
that number from the 25 (or the variable you use) and get the location of
the white space.  You may have to add or subtract 1 to account for the
reversal and such, but it would be consistant.

John Burns

-----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.

  _____
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to