The string class in Java has a trim () to remove space characters before and after a string. jquery also has the trim () method to remove strings before and after a character variable.However, there is no corresponding trim () method in JavaScript.
What exactly does the String.Trim () method do for us, just to remove the spaces at both ends of the string? Always thought that the trim () method is to delete the whitespace characters at both ends of the string, in fact I was wrong, and the wrong
The string class in Java has a trim () to remove the space characters before and after the string, and the trim () method in jquery can delete the string before and after the character variable. But there is no corresponding trim () method in
Because of the unreasonable preliminary database design, the length of the primary and Foreign keys associated with multiple tables is inconsistent. As a result, when the fields that are too long in the primary and Foreign keys are filled with the
Here we can use our own trim method to deal with the need to cut the null strings at both ends of the string. Below is a good method, if you are interested, you can refer to the JS trim method, which is not supported by many browsers. Therefore, we
For example:Select. key, B. key, C. key from A, B, C where trim (. key) = trim (B. fk) and trim (. col) = trim (C. pk ).It takes one second to associate primary Table A (more than 200 records) with Appendix B (more than 40 thousand records). This
Var trim = function (A, b) { var a = a ? a : " "; var b = b ? b : ""; if (b == "") {return ""; } var la = a.length; var lb = b.length; var s = e = false; if (B.indexOf (a) === 0 ) { s = true; } if
Use the trim () method in JQuery to remove leading and trailing spaces.
As follows:
Function bt_submit () {var $ title = $. trim ($ ("# title "). val (); if ($ title = '') {ShowMessage (" carrier name cannot be blank "," # ff0000 "); return;}
Examples of the usage of the $. trim () method in jquery.
$. Trim (str) removes spaces at the beginning and end of the string.
$. Trim (str)
Return Value: string;
Note: Remove spaces at the beginning and end of the string.
Example:First look at
The role of $.trim (str) is to remove the string and the end of the space, the following for you to describe its specific use $.trim (str) return: string; Description: Remove the string and the trailing blanks. example: First
----------------------------------js to the space---------------------------Remove the left and right side of the string space, in VBScript can easily use trim, ltrim or RTrim, but in JS there are no 3 built-in methods, you need to manually write.
Similar to the following:
Select A.key,b.key,c.key from A,b,c where trim (a.key) =trim (B.FK) and trim (A.col) =trim (c.pk).
In Table A (more than 200 records), the associated schedule B (more than 40,000 records) was used for 1 seconds, which
js implements the trim () effect of string in Java This article is from the "11831428" blog, please be sure to keep this source http://11841428.blog.51cto.com/11831428/1880593JS implementation of the Java Trim () method effect
/*** Simulate string to remove left and right side spaces *@paramStr*/ Public Staticstring Trim (String str) {Char[] List =Str.tochararray (); intLen=list.length-1; //Start Position intBeginindex=0; //End Position intendindex=Len;
Implementation of the trim method in the String class of java, stringtrim
Package stringTest; public class StringDemo4 {public static void main (String [] args) {String str = "abcdefg"; System. out. println ("original string:"); System. out.
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.