VBScript လုပ်ဆောင်ချက်ကို အစားထိုးပါ ။
❮ VBScript အကိုးအကားကို အပြီးသတ်ပါ။
Replace လုပ်ဆောင်ချက်သည် string တစ်ခု၏ သတ်မှတ်ထားသော အစိတ်အပိုင်းတစ်ခုကို အခြားစာကြောင်းတစ်ခုဖြင့် အကြိမ်အရေအတွက် သတ်မှတ်ပေးသည်။
အထားအသို
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:
|
ဥပမာများ
ဥပမာ ၁
"လှပသော" ဟူသောစကားလုံးကို "စိတ်ကူး" ဖြင့် အစားထိုးပါ။
<%
txt="This is a beautiful day!"
response.write(Replace(txt,"beautiful","fantastic"))
%>
အထက်ဖော်ပြပါ ကုဒ်၏ အထွက်သည်-
This is a fantastic day!
ဥပမာ ၂
စာလုံး "i" ကို "##" ဖြင့် အစားထိုးပါ။
<%
txt="This is a beautiful day!"
response.write(Replace(txt,"i","##"))
%>
အထက်ဖော်ပြပါ ကုဒ်၏ အထွက်သည်-
Th##s ##s a beaut##ful day!
ဥပမာ ၃
အက္ခရာ "i" ကို "##" ဖြင့် အနေအထား 15 တွင် အစားထိုးပါ။
ရာထူး 15 မတိုင်မီ စာလုံးအားလုံးကို ဖယ်ရှားကြောင်း သတိပြုပါ။
<%
txt="This is a beautiful day!"
response.write(Replace(txt,"i","##",15))
%>
အထက်ဖော်ပြပါ ကုဒ်၏ အထွက်သည်-
t##ful day!
ဥပမာ ၄
စာလုံး "i" ၏ ပထမအကြိမ် 2 ခုကို "##" ဖြင့် အနေအထား 1 တွင် အစားထိုးပါ-
<%
txt="This is a beautiful day!"
response.write(Replace(txt,"i","##",1,2))
%>
အထက်ဖော်ပြပါ ကုဒ်၏ အထွက်သည်-
Th##s ##s a beautiful day!
ဥပမာ ၅
အက္ခရာ "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!
❮ VBScript အကိုးအကားကို အပြီးသတ်ပါ။