वीबीस्क्रिप्ट इनस्ट्र फ़ंक्शन
❮ पूर्ण वीबीस्क्रिप्ट संदर्भ
InStr फ़ंक्शन एक स्ट्रिंग की पहली घटना की स्थिति दूसरे के भीतर देता है।
InStr फ़ंक्शन निम्न मान लौटा सकता है:
- यदि string1 "" है - InStr रिटर्न 0
- यदि स्ट्रिंग 1 शून्य है - InStr शून्य लौटाता है
- यदि string2 "" है - InStr रिटर्न शुरू होता है
- यदि स्ट्रिंग 2 अशक्त है - InStr अशक्त लौटाता है
- यदि string2 नहीं मिला - InStr रिटर्न 0
- यदि string2 string1 के भीतर पाया जाता है - InStr वह स्थिति देता है जिस पर मैच पाया जाता है
- यदि प्रारंभ> लेन (स्ट्रिंग 1) - इनस्ट्र रिटर्न 0
युक्ति: InStrRev फ़ंक्शन को भी देखें
वाक्य - विन्यास
InStr([start,]string1,string2[,compare])
Parameter | Description |
---|---|
start | Optional. Specifies the starting position for each search. The search begins at the first character position (1) by default. This parameter is required if compare is specified |
string1 | Required. The string to be searched |
string2 | Required. The string expression to search for |
compare | Optional. Specifies the string comparison to use.
Default is 0 Can have one of the following values:
|
उदाहरण
उदाहरण 1
<%
txt="This is a beautiful day!"
response.write(InStr(txt,"beautiful"))
%>
उपरोक्त कोड का आउटपुट होगा:
11
उदाहरण 2
विभिन्न प्रारंभिक स्थितियों का उपयोग करके "i" अक्षर ढूँढना:
<%
txt="This is a beautiful day!"
response.write(InStr(1,txt,"i") & "<br />")
response.write(InStr(7,txt,"i") & "<br />")
%>
उपरोक्त कोड का आउटपुट होगा:
3
16
उदाहरण 3
पाठ और बाइनरी के साथ "टी" अक्षर ढूँढना, तुलना:
<%
txt="This is a beautiful day!"
response.write(InStr(1,txt,"t",1) & "<br />")
response.write(InStr(1,txt,"t",0) & "<br />")
%>
उपरोक्त कोड का आउटपुट होगा:
1
15
❮ पूर्ण वीबीस्क्रिप्ट संदर्भ