Remove the space before and after.
Suppose there is a string "DDD dd D", after trim () becomes "DDD dd D".
If you can remove the extra space on both sides (including tabs), but not the middle space.
The trim () function in PHP is the same as the use of the trim () function in ASP, which is naturally used if you have been exposed to ASP.
The usage is simple, add t
Remove the space before and after.
Suppose there is a string "DDD dd D" that becomes "DDD DD D" after trim ().
You can remove extra spaces (including tabs) on either side, but you can't remove the middle space.
The trim () function in PHP is the same as the trim () function in ASP, and if you touch an ASP, it will be used naturally.
The usage is simple, add the
Remove leading and trailing spaces.Assume that there is a string "ddd dd d", which is "ddd dd d" after Trim ".You can remove unnecessary spaces (including tabs) on both sides, but do not remove spaces in the middle.The trim () function in PHP has the same usage as the trim () function in ASP. If you have been familiar with ASP, you will naturally use it.The usage
[PHP source code reading] trim, rtrim, and ltrim functions trim series functions are used to remove spaces or other characters at the beginning and end of a string. The ltrim function removes only the first character of the string. the rtrim function only removes the character at the end of the string.
Trim
String
Remove the space before and after.
Suppose there is a string "DDD dd D", after trim () becomes "DDD dd D".
If you can remove the extra space on both sides (including tabs), but not the middle space.
The trim () function in PHP is the same as the use of the trim () function in ASP, which is naturally used if you have been exposed to ASP.
The usage is simple, add
The trim () function removes spaces and other predefined characters from both ends of the string. Remove leading and trailing spaces.
Assume that there is a string "ddd dd d", which is "ddd dd d" after Trim ".
You can remove unnecessary spaces (including tabs) on both sides, but do not remove spaces in the middle.
The trim () function in PHP has the same usage
Because of the previous version of JavaScript 1.8.1, there is no built-in trim function, so JQuery has its own implementation. In different versions of jquery, the TRIM function is implemented differently.Read this article to master the use of regular expressions , if not very understanding, suggest reading this. Given the powerful use of regular expressions (which are used in various languages such as Js,p
]; BOOLIsfirstblackpoint =false; intStartX =0; intStarty =0; //Looping content matrix, writing white, black dots for(intx =0; x ) { for(inty =0; Y ) { if(Matrix.get_renamed (x, y)! =-1)//return white point/black point { if(!isfirstblackpoint) {Isfirstblackpoint=true; StartX= x;//The QR code comes with a white border, the upper-
, add it to the Array.prototype, and use it.
function Array_max () {var i, max = this[0]; for (i = 1; i After the code executes, Y saves the maximum value in the array x, or says 6.
All JScript internal objects have read-only prototype properties. You can add functionality to the prototype as in this example, but the object cannot be given a different prototype. However, user-defined objects can be assigned to a new prototype.
The list of methods and
Copy Code code as follows:
Used for trimming whitespace
Trimleft =/^\s+/,
TrimRight =/\s+$/,
Use native String.Trim function wherever possible
Trim:trim?
function (text) {
return text = null?
"" :
Trim.call (text);
} :
Otherwise use our own trimming functionality
function (text) {
return text = null?
"" :
Text.tostring (). Replace (Trimleft, ""). Replace (TrimRight, "");
},
An
Code of the enhanced JavaScript trim function
The code is as follows:
String. prototype. trim = function (){Var _ argument = arguments [0] | "";Var _ re = new RegExp ("(^" + _ argument + "*) | (" + _ argument + "* $)", "g"); // case sensitiveReturn this. replace (_ re ,"");}String. prototype. ltrim = function (){V
Copy codeThe Code is as follows:// Used for trimming whitespaceTrimLeft =/^ \ s + /,TrimRight =/\ s + $ /,// Use native String. trim function wherever possibleTrim: trim?Function (text ){Return text = null?"":Trim. call (text );}:// Otherwise use our own trimming functionalityFunction (text ){Return text = null?"":Text
CopyCodeThe Code is as follows: // used for trimming whitespace
Trimleft =/^ \ s + /,
Trimright =/\ s + $ /,
// Use native string. Trim function wherever possibleTrim: trim?Function (text ){Return text = NULL?"":Trim. Call (text );}:
// Otherwise use our own trimming functionalityFunction (text ){Return text = NU
. prototype, and use it.Function array_max () {var I, max = This [0]; for (I = 1; I After the code is executed, y saves the maximum value in array X, or 6.All internal JScript objects have the read-only prototype attribute. You can add features for the prototype as in this example, but the object cannot be assigned different prototypes. However, user-defined objects can be assigned to new prototypes.The method and attribute list of each internal objec
, and use it.Function array_max () {var I, max = this [0]; for (I = 1; I After the code is executed, y saves the maximum value in array x, or 6.All internal JScript objects have the read-only prototype attribute. You can add features for the prototype as in this example, but the object cannot be assigned different prototypes. However, user-defined objects can be assigned to new prototypes.The method and attribute list of each internal object in this l
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.