Today, I made a long mistake at the company. It may be due to my carelessness.
Segment firstCode:
String id = Params. Get ("ID") + "";
If (null = ID | "". Equals (Id. Trim ())){
// When ID is null
..................
} Else {
...................
}
Let's see what is wrong with this code. I couldn't think of it for a long time. However, when ID is null, it always enters the else block. Where is the error of IF (null = ID | "". Equals (Id
// Function: trim (), ltrim (), and rtrim () functions of JavaScript// Source: http://jorkin.reallydo.com/article.asp? Id = 460String. Prototype. Trim = function (){Return this. Replace (/(^ \ s *) | (\ s * $)/g ,"");}
String. Prototype. ltrim = function (){Return this. Replace (/(^ \ s *)/g ,"");}
String. Prototype. rtrim = function (){Return this. Replace (/(\ s * $)/g ,"");}
// The following
When it comes to converting or editing image files in Linux, ImageMagick is undoubtedly one of the most well-known integrated software. It contains a complete set of command-line tools to display, convert, or copy raster or vector image files of more than 200 types, all at the command line. ImageMagick can be used for a variety of image editing tasks, such as converting file formats, adding special effects, adding text, and changing images (resizing, rotating, flipping, cropping).If you want to
JS Remove the space instance trim (), LTrim (), RTrim () need friends can come to the reference, I hope to help you1, JS Remove the string of space//to the left space; function LTrim (s) ... {return S.replace (/(^s*)/g, "");} Go to the right space; function RTrim (s) ... {return S.replace (/(s*$)/g, "");} Go to the left and right space; function trim (s) ... {//s.replace (^s*) | ( s*$)/g, ""); return RTrim
) characteristics;
3. NFA eager to desire, so the most Zokozheng-style priority matching success, so occasionally miss the best match results, the DFA is "the longest Zokozheng-style priority matching success."
4. NFA defaults to the use of greedy quantifiers (that is, for/.*/,/\w+/such a "repeat n" mode, in a greedy manner, as much as possible to match more characters, until not to stop), the NFA will give priority to match quantifiers.
5. The NFA may fall into the trap of recursive calls and p
The example in this article describes how PHP uses the Trim function to remove the left and right spaces and special characters of a string. Share to everyone for your reference, specific as follows:
the trim () function in PHP is defined as follows :
Trim (string,charlist)
The parameter description is as follows:
String required. Specify the string to check.
Tags: matching blank img Delete processing ges blog images fieldIn some cases, the value of some fields in the data table will appear with a white-space character if the program is not handled properly, asThis will not match if it is strictly compared to name. The trim () function solves this problemAs a subset of the trim () function, the LTrim () function is the special character that handles the left sid
A few of the commands used in the Tutorial: line (This is needless to say!). Point (dot) ARRAY (display)
Lengthen (elongation) Attdef (attribute definition) block (definition blocks) Insert (insert block) EXPLODE (explode).
Effect picture!
Now
The shell implements the trim function effect to remove spaces on both sides of the string, and the following three commands are equivalent, all of which can be implementedSed ' s/^\s*//' totrim.txt |sed ' s/\s*$//' >trimed.txtSed ' s/^\s*//;s/\s*$//' totrim.txt>trimed.txtSed-e ' s/^\s*//'-e ' s/\s*$//' totrim.txt>trimed.txtThe main thing is to use regular expressions, ^\s* represents 0 or more spaces in front of a string, and \s*$ represents 0 or mor
(1) Flat arrayThis is a well-known internet company today's front-end written questions: multidimensional array dimension variable, such as [2,4,1,[2,3,4,[1,2],5,3],3,8] beat flat for [2,4,1,2,3,4,1,2,5,3,3,8]. The number of dimensions is variable and should be recursive:Answer:function flatten(arr){var arrLength=arr.length;fori=0;ii++){ if(arr[i].constructor==Array){ arr.splice(i,1,flatten(arr[i])); }}return arr;}(2) Extract the parameters from the URL into an objectThis is also an
;background– Displays the container's grid background.Type: Boolean default:true;autocrop– When initializing, the image can be generated automatically.Type: Boolean default:trueautocroparea– defines the auto crop area size (in percent) and the picture to compare.Type: Number default: 0.8; is the size of the crop box displaymovable– allows you to move the back imageType: Boolean default:true;rotatable– Whether the image is allowed to be rotated.Type: Boolean default:true;scalable– Whether the ima
As shown below:
function Bt_submit () {
var $title = $.trim ($ ("#title"). Val ());
if ($title = = ") {
showmessage (" operator name cannot be empty "," #ff0000 ");
return;
}
Document.all.form1.submit ();
}
The HTML code is as follows:
The above use of jquery in the trim () method to remove before and after the space is small to share all the content of everyone, hope to give you
But if the project does not use the framework such as jquery, JS itself does not have such a function, we have to write their own functions, the following is the specific implementation of the function:
Copy Code code as follows:
For consumer calls
function Trim (s) {
Return TrimRight (Trimleft (s));
}
Remove the left blank
function Trimleft (s) {
if (s = = null) {
Return "";
}
var whitespace = new String ("\t\n\r");
----------------------------------JS to Space----------------------------------Remove the space between the left and right sides of the string, you can easily use trim, LTrim, or RTrim in VBScript, but in JS there are no 3 built-in methods that need to be written manually. The following implementation method uses regular expressions and is efficient and adds these three methods to the built-in methods of the string object. The methods written in the
$.trim (str)
Back: string;
Description: Remove the string and end space.
Example:
First look at the error code error code:
Copy Code code as follows:
var content = $ (' #content '). Val ();
if (content.trim () = = ")
Alert (' empty ');
The above writing in Firefox will not be an error, but under IE will be an error
So write the following format:
Copy Code code as follows:
var content = $ (' #results '). Val (
The method written as a class is as follows: (Str.trim ();) We use regular expressions to manipulate
The code is as follows
Copy Code
or write that.
The code is as follows
Copy Code
function Trim (str) {for (var i = 0; Ifor (var j =str.length; J>0 Str.charat (j-1) = = ""; j--);if (i>j) return "";Return str.substring (I,J);}
This can be written as a function: (
Tags: Pre err from local set round str user prefixTrim is a formatted tag that can perform the functions of a set or a where tag. Trim Properties:prefix: Prefixes overwrite and increase their contentssuffix: Suffix overrides and increases its contentsPrefixoverrides: The condition of the prefix judgmentSuffixoverrides: Suffix judgment Condition 1, select * from user name = ' xx ' and gender = ' xx ' in the place where the red mark is not present the
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.