asp字元擷取

時間 2022-12-12 06:10:44

1樓:匿名使用者

instr(string1,string2[, compare]) 返回string2字串在string1字串中第一次出現的位置。

所以可以用。

mid(a,(instr(a,"的")-3),7))測試。

a="我我我我我我我我我的我我我我我我我",(instr(a,"的")-3),7))%

成功輸出"我我我的我我我"

這是最簡單的。

也可以如下方式:

用split()把字串分割成以"的"為分隔符的陣列,而這個陣列只有二項,索引從0開始。

str=split(a,"的")

哪麼前面一段為。

str(0)

後面一段為。

str(1)

現在前面一段取右邊3個字。

right(str(0),3)

後面一段取左邊32上字。

lift(str(1),3)

前面+"的"+後面。

=right(str(0),3)&"的"&lift(str(1),3)

我教了你二個方法四個函式,請給我加分吧,呵呵。

2樓:網友

這樣就可以:

str="我我我我我我我我我的我我我我我我我"

str=split(str,"的")

right(str(0),3)&"的"&left(str(1),3)

3樓:土豆_地瓜

把「的」的位置找到,然後用mid()取左三右三組成新串。

4樓:網友

...這個不能吧!!!可能是我水平有限。。對不起!不能幫到你!

asp擷取字串的函式怎麼寫,asp擷取字串

left 字串,擷取長度 mid 字串,起始位置,擷取長度 function cutstr str,nums,uns 字串擷取 if len str 1 or not isnumeric n then exit function lw strlength str if lw nums then cu...

asp擷取字串長度

你沒搞懂伺服器端的變數和瀏覽器端的變數不能通用。你要這樣寫 反正我寫的傳值是正確的,我寫的程式就是這樣傳值的。至於你說沒用肯定還有其它問題。寫在你的asp迴圈裡 dim neirong neirong nohtml s s是你的資料變數if len neirong 4 thenresponse.wr...

asp過濾字元警告錯誤,ASP過濾字元警告錯誤

if instr comments,arr i 0 then response.write response.end end if 寫成for i 0 to ubound arr if instr comments,arr i 0 then response.write response.end e...

怎麼用VB擷取多行字串,VB如何擷取指定字元後面的N個字元

text2.text split text1.text,vbcrlf 1 輸出第二項 text2.text split text1.text,vbcrlf 2 輸出第3項 其中vbcrlf是回車換行符 split 函式是把字串轉換為陣列,vbcrlf是分隔符。用split函式 dim str as ...

ASP字串查詢是否含有指定字元

a 雖然他是乙隻驕傲的孔雀,算不上是王子殿下 b 孔雀,王子,驕傲 c instr b,a response.write c 如果instr裡面存在相關字元的話,返回所在的位置,如果,不存在的話,返回0 不會返回負數 instr 函式 返回某字串在另一字串中第一次出現的位置。instr start,...