वीबीस्क्रिप्ट फ़ंक्शन बदलें
❮ पूर्ण वीबीस्क्रिप्ट संदर्भ
बदलें फ़ंक्शन एक स्ट्रिंग के एक निर्दिष्ट भाग को दूसरी स्ट्रिंग के साथ एक निर्दिष्ट संख्या में बदल देता है।
वाक्य - विन्यास
Replace(string,find,replacewith[,start[,count[,compare]]])
Parameter | Description |
---|---|
string | Required. The string to be searched |
find | Required. The part of the string that will be replaced |
replacewith | Required. The replacement substring |
start | Optional. Specifies the start position. Default is 1. All characters before the start position will be removed. |
count | Optional. Specifies the number of substitutions to
perform. Default value is -1, which means make all possible substitutions |
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(Replace(txt,"beautiful","fantastic"))
%>
उपरोक्त कोड का आउटपुट होगा:
This is a fantastic day!
उदाहरण 2
"i" अक्षर को "##" से बदलें:
<%
txt="This is a beautiful day!"
response.write(Replace(txt,"i","##"))
%>
उपरोक्त कोड का आउटपुट होगा:
Th##s ##s a beaut##ful day!
उदाहरण 3
"i" अक्षर को "##" से बदलें, जो स्थिति 15 से शुरू होता है:
ध्यान दें कि स्थिति 15 से पहले के सभी वर्ण हटा दिए जाते हैं।
<%
txt="This is a beautiful day!"
response.write(Replace(txt,"i","##",15))
%>
उपरोक्त कोड का आउटपुट होगा:
t##ful day!
उदाहरण 4
"i" अक्षर के 2 पहले अवसरों को "##" से बदलें, जो स्थिति 1 से शुरू होता है:
<%
txt="This is a beautiful day!"
response.write(Replace(txt,"i","##",1,2))
%>
उपरोक्त कोड का आउटपुट होगा:
Th##s ##s a beautiful day!
उदाहरण 5
अक्षर "t" को "##" से बदलें, टेक्स्टुअल और बाइनरी के साथ, तुलना:
<%
txt="This is a beautiful day!"
response.write(Replace(txt,"t","##",1,-1,1) & "<br />")
response.write(Replace(txt,"t","##",1,-1,0))
%>
उपरोक्त कोड का आउटपुट होगा:
##his is a beau##iful day!
This is a beau##iful day!
❮ पूर्ण वीबीस्क्रिप्ट संदर्भ