Truncate String

Post your working scripts, libraries and tools
User avatar
Capn Odin
Posts: 1274
Joined: 23 Feb 2016, 19:45
Location: Denmark

Truncate String

30 Sep 2016, 13:30

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
Last edited by Capn Odin on 03 Oct 2016, 11:23, edited 3 times in total.
Please excuse my spelling I am dyslexic.
ozzii
Posts: 291
Joined: 30 Oct 2013, 06:04

Re: Truncate String

03 Oct 2016, 01:39

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?
User avatar
Capn Odin
Posts: 1274
Joined: 23 Feb 2016, 19:45
Location: Denmark

Re: Truncate String

03 Oct 2016, 10:37

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.
Please excuse my spelling I am dyslexic.
ozzii
Posts: 291
Joined: 30 Oct 2013, 06:04

Re: Truncate String

04 Oct 2016, 01:38

Didn't saw the dot parameter ;)

Return to “Scripts and Functions”

Who is online

Users browsing this forum: No registered users and 12 guests