Page 1 of 1

Truncate String

Posted: 30 Sep 2016, 13:30
by Capn Odin
I doubt anyone will be interested in this but I made a set of functions to truncate strings from start, end or middle of the string, both in general or only on words.

Code: [Select all] [Expand] [Download] (Truncate.ahk)GeSHi © Codebox Plus

The functions returns a substring of the parameter String that they are called with of a length no greater than Length and containing an optional ... at the start, middle or end.

Test

Re: Truncate String

Posted: 03 Oct 2016, 01:39
by ozzii
Cool.
If I may some suggestions for having this a little more complete (at least for me):
-Add to not have the dots (...)
-Add to extract the Nth word (for example word #2 from left or right)
What do you think?

Re: Truncate String

Posted: 03 Oct 2016, 10:37
by Capn Odin
ozzii wrote:-Add to not have the dots (...)
The fourth parameter Dots already allowed for this, however I think I will add a space when calculating Truncate_Middle without dots.

ozzii wrote:-Add to extract the Nth word (for example word #2 from left or right)
I will have to think about it, can't promise anything. It may need its own function ?

Edit: Oh, guess I forgot to explain that the dots where optional, when I described the returned string.

Re: Truncate String

Posted: 04 Oct 2016, 01:38
by ozzii
Didn't saw the dot parameter ;)