JQuery determines whether an element is included in the array, the letter case conversion function to determine whether the string contains specific characters,

var arry = [ "C#", "html", "css", "JavaScript" ]; 
var result= $.inArray("C#", arry);
var mstr="AbcEa";
mstr.toLowerCase () ------ Convert all characters in the string to lower case;
mstr.toUpperCase () ------ Convert all characters in the string to uppercase;

Use indexOf () and lastIndexOf () methods

var Cts = "bblText"; 
if(Cts.indexOf("Text") >= 0 ) { 
    alert ( 'Cts contains Text string' );
} 

Returns the character position of the first occurrence of a substring within a String object.
strObj.indexOf (subString [, startIndex])


parameter:

strObj (required
. String object or text.) subString (required . Substring to be found in the String object.)
starIndex (optional. The integer value indicates the index to start the search within the String object. If omitted, then Find from the beginning of the string.)


The
indexOf method returns an integer value that indicates the starting position of the substring within the String object. If no substring is found, -1 is returned. If startindex is negative, startindex is treated as zero. If it is larger than the largest character position index, it is regarded as the largest possible index. Perform the search from left to right. Otherwise, the method is the same as lastIndexOf.

note:

The indexOf () method is case sensitive! If the string value to be retrieved does not appear, the method returns -1. The usage of lastIndexOf () is the same as indexOf (), except that you want to search from the right to the left.

Guess you like

Origin www.cnblogs.com/firstcsharp/p/12720543.html