Loudtalks — internet walkie talkie

It's all about passion

We develop custom software for small businesses and entrepreneurs and we do it with passion. What does it mean? We care about what we do. We treat our customers' projects as if they were ours. We deliver personal service and always do our best to offer more value and be more efficient. We innovate. We rely on bright people rather than on formal procedures. It's all about passion, passion about making the best software in the world in the most efficient way.
Metalink's primary focus is:
Our customers list includes start-ups and small businesses from USA, Australia, England, China and Singapore. If you are looking for fast and iterative development performed by young, innovative and mobile team then you are on the right page.
Alexey Gavrilov
Alexey Gavrilov
Commercial director
It’s kind of weird to write about myself from 3rd party perspective so I won’t even try. Now I suppose you guessed that I’m the guy who wrote the copy for this website. This is quite natural as I’m responsible for Metalink’s marketing efforts in US / Western markets. Along with Veronika I’m one of company founders and I really devote a big part of myself to this venture ...
More people

trim() function for ActionScript and JavaScript

By Alexey Gavrilov on February 7, 2010

Strangely ActionScript doesn’t have trim() function, JavaScript doesn’t have it either.

I needed the one lately and googled it but a few solutions that came up looked weird (using several for() cycles for example). So I came up with this one — if you know how to make it simpler or shorter, l’d be very interested to hear your solution.

Old school style:


function trim(s) {
    return s.match(/^s*(.*?)s*$/)[1];
}

var s = trim(" well done   "); // s = "well done"
 

Modern style:


String.prototype.trim = function() {
    return this.match(/^s*(.*?)s*$/)[1];
}

var s = "   even better  ".trim(); // s = "even better"
 

Enjoy!

(categories: Technology, Solutions box)