in reply to Re^2: how to shorten given string?
in thread how to shorten given string?

Others here are better (and faster) with regexps than I. They have provided answers below. My question to you would be:
What is the reason for wanting to use a regex to perform a substr on a string when there's a substr function already?

Replies are listed 'Best First'.
Re^4: how to shorten given string?
by mellin (Scribe) on Oct 13, 2004 at 19:25 UTC
    Just to understand better of the meanining of code i'm writing , nothing more :) Thank you all very much. Next thing to do would be including three dots like "..." after the shortened string, but if only the string was longer than given length. Like printing "Ipod batteries for Apple iPod...", because original string exceeded 30 chars. If the string fits under given amount of characters, it is displayed as is. I'll try to implement that now, but if you guys are faster, feel free, please :P