Recommended: Use Osql tools to manage SQL Server Desktop Engine (MSDE 2000) application introduction The SQL Server desktop engine (also called MSDE 2000) does not have its own user interface because it is mainly designed to run in the background.
The IndexOf() method of the string searches whether a string passed as a parameter appears on the string. If a string is found, it returns the starting position of the character (0 means the first character, and 1 means the second character according to the and so on) If no found, return -1Returns the character position of the first substring in the String object.
Copy the code as follows: www.CuoXIn.com
public indexOf(value:String, [startIndex:Number]) : Number
Searches for the string and returns the position of the first match of the value found on or after the startIndex position within the call string. This index starts at zero, which means that the first character in the string is considered to be at index 0 rather than index 1. If no value is found, the method returns -1.
parameter
value:String - A string; a substring to search for.
startIndex:Number [optional] - An integer that specifies the start index of the search.
return
Number - Specifies the position of the first match of the substring, or -1.
-------------------------------------------------- -------------------------------------------------- ----------------------------------------------
indexOf method
Returns the character position of the first substring in the String object.
strObj.indexOf(subString[, startIndex])
parameter
strObj
Required option. String object or text.
subString
Required option. The substring to look for in the String object.
starIndex
Optional. This integer value indicates the index that begins searching within the String object. If omitted, look up from the beginning of the string.
illustrate
The indexOf method returns an integer value indicating the start position of the substring inside the String object. If no substring is found, return -1.
If startindex is a negative number, startindex is treated as zero. If it is larger than the largest character position index, it is regarded as the largest possible index.
Perform a lookup from left to right. Otherwise, the method is the same as lastIndexOf.
Example
The following example illustrates the usage of the indexOf method.
Copy the code as follows: www.CuoXIn.com
function IndexDemo(str2){
var str1 = "BABEBIBOBUBABEBIBOBU"
var s = str1.indexOf(str2);
return(s);
}
Example:
I get a string a is "1,18,33"
If you write it as a indexOf("1"), it seems that you can't find it out. More importantly, there is a 1 in front of 18 and 1, so the conditions for the validity are inaccurate. How should you write it?
Use indexOf in this way
Copy the code as follows: www.CuoXIn.com
string test = "1,18,33";
if (test.IndexOf("1") > -1)
{
Response.Write("exist");
}
else
{
Response.Write("not exist");
}
But if only 1 meets the requirements and 1 of 18 does not meet the requirements, then you cannot use IndexOf to do it.
Copy the code as follows: www.CuoXIn.com
using System.Text.RegularExpressions;
string test = "1,18,33";
if (Regex .IsMatch(test, @"/b1/b"))
{
Response.Write("exist");
}
else
{
Response.Write("not exist");
}
Notes:
/b Match a word boundary in a regular
Write a method
Copy the code as follows: www.CuoXIn.com
//src source string
//tar string to be compared
private bool CheckString(string src, string tar)
{
string temp = Regex.Replace(tar, @"[.$^{/[(|)*+?//]", "");
if (temp.Length < tar.Length)
return false;
if (Regex.IsMatch(src, @"/b" + tar + @"/b"))
return true;
return false;
}
Share: What format is asp and what to open asp files Today, someone in the group asked what format is asp and what to open the asp file. In fact, asp is the background language of Microsoft. Many websites are websites made with asp. Although PHP is used more now, I will briefly introduce it here.