xsl-list
[Top] [All Lists]

Re: [xsl] Algorithm for splitting a string at a space

2015-11-23 16:12:19
On Mon, 2015-11-23 at 19:05 +0000, Rick Quatro rick(_at_)rickquatro(_dot_)com
wrote:
Hello,

I have a series of strings that I need to split if they are longer
than a
particular length, say 30 characters. But I need to make the split at
the
previous space.

What I do is something like,
(1) use substring to truncate at 30 characters
(2) remove a trailing space and any number of not-space characters
    with replace()
(3) if there's nothing left, use the first 27 characters followd by ...
or … 

That's probably the same as David's algorithm in effect.

Liam


-- 
Liam R. E. Quin <liam(_at_)w3(_dot_)org>
The World Wide Web Consortium (W3C)
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>