How To trim() in JavascriptMarch 17th, 2006 Javascript doesn't natively support trim on strings. It is however very easy to implement with regular expressions.
HSQLDB Tip: Case Insensitive LIKE Query in HSQLDB RDBMS & Space Crunched String ComparisonJuly 21st, 2007 I previously discussed how to extend HSQLDB relational database with simple Java functions. The example there actually implements case insensitive like query functionality for HSQLDB.
Program (Source Code) to Trim Whitespaces from Files...April 20th, 2008 PHP is not only a very competent web development language (and part of LAMP stack). It is also a very capable language for writing (command line) scripts.
How To Split Java String By NewlinesJuly 19th, 2007 Splitting a String by newline is a common requirement. When processing textual data from files or from web we need to split the data by newline boundaries.
How To Compress JavaScript Files SafelyJuly 4th, 2006 List of high quality javascript compressors. Feel free to add to this list in your comments.
Java Program: Compare two text filesApril 29th, 2009 Today while managing the comments, I got a request of this sort. HI,
I have a small question in java.
How To Delete Property From java.util.PropertiesAugust 23rd, 2008 This isn't a trick question. For a long time you couldn't delete a property from java.util.Properties class.
How To Debug Execution Path in PHP...Equivalent of printStackTrace() in JavaMarch 1st, 2007 While programming in PHP often you will find that a simple echo or log statement is not sufficient. You have found out where a problem is happening but you have no clue why it is executing that code in the first place.
Developing Clean AJAX / Javascript Driven Websites; Say No To Tag-SoupNovember 13th, 2005 Behaviour promotes itself as "the missing link for your AJAX apps". It allows you to use CSS selectors (like id or class) to apply Javascript behaviors to your HTML elements.
Discussion & Examples: Java enums versus public static finalSeptember 23rd, 2008 Should we use to represent a constant String such as browser's user agent or simply use public static final String as before?
Using public static final as enum has many problems, such as:
Not typesafe - Since a type is just an int you can pass in any other int value where a particular type is required, or add two types together (which makes no sense). This is particularly noticeable in C programs where you will find strange constants being used in un-related place and yet it seems to work, simply because the required constant and the provided constant share the same int value.
Little Painful Javascript QuirkMay 14th, 2006 Why doesn't document.getElementById('location').value work as function parameter in Javascript?
What does work is:
var temp = document.getElementById('location');
temp.value works fine as function parameter. Apparently javascript doesn't like referencing fields directly on functions as in getElementById('location').value as a function parameter.
Biggest Internet Explorer Problem With JavascriptJuly 26th, 2007 You would be surprised to know that the biggest Internet Explorer issue I am facing while writing rather complex cross-browser javascript code is related to just a comma. In javascript array if you add a comma after the last element in the array then Internet Explorer fails with a variety of undecipherable (Microsoft style) error messages.
Angsuman's WordPress 2.0 / 1.5.x Dashboard Replacement: How to Trim The Fat Resource Hogging WordPress Admin DashboardDecember 27th, 2005 WordPress developers are adding their preferred feeds to WordPress Admin Dashboard (from WordPress 1.5 onwards), which significantly slows up loading the Admin Dashboard. Additionally few essential information has been removed frfom the official version of admin dashboard and also some information moved to hard-to-get locations in order to accomodate their copious feed data.
How To Use SAJAX (AJAX Framework) from HTMLMay 15th, 2006 Sajax is an useful ajax framework to simplify ajax based development for languages like PHP, Ruby etc. Not many realize Sajax can be used equally well from plain old html pages (as in .html or .htm).
WordPress 2.0 & 1.5.x Hack: How to trim the fat resource hogging Admin DashBoard (Version 2)April 18th, 2005 Drop in replacement for resource hogging Admin DashBoard in WordPress 2.0, 1.5.x
September 16th, 2007 at 11:50 pm
Hi Sir,
The topic is very useful.But in this form it will not work.We have to put dot(.) after String instead of space.
String.prototype.trim = function() {
a = this.replace(/^s+/, ”);
return a.replace(/s+$/, ”);
};
December 27th, 2007 at 11:18 pm
Sir,
I am striking with trim() option in Java script
I have a one string,
A = “E:\ram\Collections\t1.jpeg”
I need,
ans = “E:\ram\Collections\” only
Please kindly help me. I can use the trim function but it not use.
Thanks & Regards
T.R.Harihara sudhan
May 11th, 2009 at 9:01 am
Modified it to make it work correctly….
String.prototype.trim = function() {
a = this.replace(/^[ \t]+|[ \t]+$/, ”);
return a.replace(/^[ \t]+|[ \t]+$/, ”);
};
var str=’ this is sample ! ‘;
alert(str.length);
alert(’trimmed !’);
alert(str.trim().length);