Javascript - trim() function

Last update on July 15, 2009 10:53 AM by deri58
Published by jad05

[Javascript] The trim() function









The trim () function is native PHP (and other languages) and is used to remove the spaces at the beginning and end of the string. There is no such function in Javascript, but you can use the following code to get the same results:

Function trim (myString)
{
return myString.replace(/^\s+/g,'').replace(/\s+$/g,'')
}
Best answers for « Javascript trim() function » in :
Command file with card system in Fortran90 Show Command file with card system in Fortran90 I. Introduction Fortran is a general-purpose programming language that is especially used for numeric computation and scientific computing. In a code, when digital data need to be...
Javascript - split () Show [Javascript] The split () function The split () function allows you to split a string and return the results in a table, using a string defined as a separator. In the example below, the split () can cut the date according to the...
Escape an apostrophe under javascript Show Escape an apostrophe under javascript In Javascript, an apostrophe (single quote) into a string itself enclosed by apostrophes cause an error. To troubleshoot, you should escape the apostrophe by heading the backslash character to get...
[PHP]Detect the display resolution Show[PHP]Detect the display resolution PHP does not possess any function allowing detection of the display resolution. The solution is to make use of Javascript to detect the resolution through the width and height attributes of the...
Soople.com - All Google function Showsoople.com - All Google function Soople is a website that offers all the functions of Google with a more simplified and attractive graphical interface(see below). It has been created for people who are not familiar with Google. This...
[Javascript]Knowing the height of an HTML element Show[Javascript]Knowing the height of an HTML element To determine the height of a HTML block using JavaScript, independently from the type browsers used, there are two methods: element.offsetHeight...
Download AJAX and JavaScript Barcode Generator ShowAJAX and Javascript Barcode Generator is a barcode generator for AJAX and Javascript applications. As it is a native Java script code, no additional components, fonts or plug-ins are necessary; it is a complete barcode generator. It can supports...
Spreadsheets - Logic Functions ShowThe Concept of a Function Spreadsheets generally have a large number of integrated functions for processing data. There are hundreds, categorised as follows: Arithmetic functions that offer basic tools to process numerical data Statistical...
Spreadsheet - Functions ShowThe Concept of a Function Spreadsheets generally have a large number of integrated functions for processing data. There are hundreds, categorised as follows: Arithmetic functions that offer basic tools to process numerical data Statistical...
Spreadsheets - Arithmetic Functions ShowThe Concept of a Function Spreadsheets generally have a large number of integrated functions for processing data. There are hundreds, categorised as follows: Arithmetic functions that offer basic tools to process numerical data Statistical...