 |
|
asp การตัดคำอันนี้ใช้ได้ดีค่ะแต่ต้องการเพิ่มอีกนิดค่ะ คือต้องการให้ตัดคำเมือมีการเคาะหรือเว้นวรรคนะคะ ในที่นี้คือหลัง .co.th |
|
 |
|
|
 |
 |
|
Code (ASP)
str = "I use www.google.co.th to search the internet"
if instr(str," ") <> 0 then
str = split(str," ")
for i = 0 to ubound(str)
if str(i) <> "" then
response.write "<br>"& str(i)
end if
next
else
response.write str
end if
ลองอย่างนี้ดูครับ ว่าใช่หรือเปล่า
|
 |
 |
 |
 |
Date :
2013-05-11 09:03:44 |
By :
thep |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
str = "I use http://www.google.co.th to search the internet" '(ในส่วนที่ไม่ได้ระบุ http://)
'จะเพิ่มโค้ดอย่างไร กรณีที่มี http:// หรือมีแต่คำว่า www ก็ให้ตัดได้เหมือนกันนะคะ และในส่วนของการลงท้าย .com?sss=1 ok ให้ตัดเมื่อมีการเคาะหรือช่องว่างนะคะ
Code (ASP)
if instr(str,"www.") <> 0 then
if instr(str,"http://") <> 0 then
str = right(str,len(str) - instr(str,"http://www.") +1)
else
str = right(str,len(str) - instr(str,"www.") +1)
end if
if instr(str," ") <> 0 then
str = split(str," ")
strVal = str(0)
end if
end if
response.write strVal
|
 |
 |
 |
 |
Date :
2013-05-11 09:45:05 |
By :
thep |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|