This extension splits the string by given separator and returns an array with trimmed items. It uses the trim() extension at trim a string from white space by JavaScript function or Another JavaScript function for trim a string from white space.
Regular expressions are a powerful tool for performing pattern matches in Strings in JavaScript.You can perform complex tasks that once required lengthy procedures with just a few lines of code using regular expressions.It is implemented at below function.
// here is the function splitrim
String.prototype.splitrim = function(t){
return this.trim().split(new RegExp(’\\s*’+t+’\\s*’))
}
//from here is the test code for splitrim
str = ‘ Hello, World! Only a test. ‘;
var arr = str.splitrim(’,’);
document.write (’“’ + arr[0] + ‘”’);
document.write (’“’ + arr[1] + ‘”’);
document.write (’“’ + arr[2] + ‘”’);
document.write (’“’ + arr[3] + ‘”’);

January 31st, 2008
Ntt.cc
Posted in
Tags: 
RSS Feed
Email Feed
[...] by JavaScript function ( or Another JavaScript function for trim a string from white space ) and JavaScript function-Splits the string by given separator and returns an array with trimmed items, Some Regular expressions have been used. Regular expressions are very powerful tools for [...]
this does not help