Truncate String

Post a reply


In an effort to prevent automatic submissions, we require that you type the text displayed into the field underneath.
Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :| :mrgreen: :geek: :ugeek: :arrow: :angel: :clap: :crazy: :eh: :lolno: :problem: :shh: :shifty: :sick: :silent: :think: :thumbup: :thumbdown: :salute: :wave: :wtf: :yawn: :facepalm: :bravo: :dance: :beard: :morebeard: :xmas: :HeHe: :trollface: :cookie: :rainbow: :monkeysee: :monkeysay: :happybday: :headwall: :offtopic: :superhappy: :terms: :beer:
View more smilies

BBCode is ON
[img] is OFF
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Truncate String

Re: Truncate String

Post by ozzii » 04 Oct 2016, 01:38

Didn't saw the dot parameter ;)

Re: Truncate String

Post by Capn Odin » 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.

Re: Truncate String

Post by ozzii » 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?

Truncate String

Post by Capn Odin » 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]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

Top