Php learns to delete string whitespace characters. You can use Trim (), LTrim (), RTrim () functions to remove whitespace from the string masthead or end: $trimmed = Trim (String[,charlist]), $trimmed = LTrim (String[,charlist]); trimmed = RTrim
In javascript, if you want to remove spaces between the left and right sides of the string, you can use the trim, ltrim, or rtrim function in vbs, and you will find an error, if you do not have these three functions in js, You need to customize them.
Today, when I was writing JavaScript, I encountered an error. The JS Code is as follows:
// Verify the regular expression of the date format. For example
Function isdate (STR )...{
VaR days = new array (, 31 );
VaR A = Str. match (/^ (d... {4}) (-)
About trim in fact, nothing to say, is to remove the first space, for modern browsers is simply a regular/^\s+|\s+$/can be done.JavaScript Regular expressions implement trim ()
The code is as follows
Copy Code
Js custom trim function to delete spaces at both ends, jstrim
This article describes how to delete spaces at both ends of a js custom trim function. We will share this with you for your reference. The details are as follows:
Compatible with
Compared to Vbscript,javascript is already very powerful in string processing, but there is no need to remove the space before and after the trim method.
Clear the right and left spaces
function trim (s) {return
trimright trimleft (s));
}
Js remove space instance Trim (), LTrim (), RTrim () need friends can come to refer to, hope to help everyone
1. Remove string spaces in js// Remove the left space;
Function ltrim (s)
...{
Return s. replace (/(^ s *)/g ,"");}// Remove the
1. JavaScript overview
2. JavaScript Introduction method
3. JavaScript Language Specification
4. JavaScript Language Basics
5. JavaScript data type
6. JavaScript operators
7. JavaScript Process Control
8. JavaScript
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.