ศูนย์สาธิตสถานีเย็นที่ใหญ่ที่สุดในประเทศจีน!
คลาสนี้ใช้ในการประมวลผลสตริงซึ่งเขียนโดยชาวต่างชาติ
วิธีใช้:
-
<!-#รวมไฟล์ = stringoperations.asp->
-
DIM STR
ตั้งค่า str = new StringOperations
ทดสอบ = str.tocharray (ตรวจสอบสิ่งนี้)
Response.write <strong> str.tocharray </strong>::
สำหรับ i = 0 ถึง Ubound (ทดสอบ)
Response.write Test (I) &
ต่อไป
Response.write <br> <br>
test1 = stra.arraytring (ทดสอบ)
Response.write <strong> str.arraytring </strong>: & test1
Response.write <br> <br>
Response.write <strong> str.startswith </strong>: & str.startswith (test1, ch)
Response.write <br> <br>
Response.write <strong> str.endwith </strong>: & strongswith (test1, out)
Response.write <br> <br>
Response.write <strong> str.clone </strong>: & str.clone (abc, 10)
Response.write <br> <br>
Response.write <strong> str.trimstart </strong>: & strimstart (test1, 3)
Response.write <br> <br>
Response.write <strong> str.trimend </strong>: & strongr.trimend (test1, 2)
Response.write <br> <br>
Response.write <strong> str.swapcase </strong>: & str.swapcase (hihihi) (hihihi)
Response.write <br> <br>
Response.write <strong> str.isalphabetic </strong>: & str.isalphbetic (!)
Response.write <br> <br>
Response.write <strong> str.capitalize </strong>: & str.capitalize (Clara Fehler)
ตั้งค่า str = ไม่มีอะไร
-
=============== stringoperations.asp =================
-
คลาส Stringoperations
'*********************************************************** ******************************************************** ******************************************************** ******************************************************** ******************************************************** **************, ********************************************* **
'' @function คำอธิบาย: แทนที่สตริงเป็นอาร์เรย์ประเภทถ่าน
'' @parameter คำอธิบาย: -dr [String]: สตริงที่ต้องแปลง
'' @return value: - [อาร์เรย์] อาร์เรย์ประเภทถ่าน
'*********************************************************** ******************************************************** ******************************************************** ******************************************************** ******************************************************** **************, ********************************************* **
ฟังก์ชั่นสาธารณะ
Redim Chararray (Len (Str))
สำหรับ i = 1 ถึง len (str)
chararray (i-1) = mid (str, i, 1)
ต่อไป
tocharray = chararray
ฟังก์ชันสิ้นสุด
'*********************************************************** ******************************************************** ******************************************************** ******************************************************** ******************************************************** **************, ********************************************* **
'' @function คำอธิบาย: แปลงอาร์เรย์เป็นสตริง
'' @parameter คำอธิบาย: -arr [array]: ข้อมูลที่จำเป็นต้องได้รับการแปลง
'' @return value: - [String] String
'*********************************************************** ******************************************************** ******************************************************** ******************************************************** ******************************************************** **************, ********************************************* **
ฟังก์ชั่นสาธารณะ (byval arr)
สำหรับ i = 0 ถึง Ubound (arr)
strobj = strobj & arr (i)
ต่อไป
arraytring = strobj
ฟังก์ชันสิ้นสุด
'*********************************************************** ******************************************************** ******************************************************** ******************************************************** ******************************************************** **************, ********************************************* **
'' @function คำอธิบาย: ตรวจสอบว่าสตริงต้นทางเริ่มต้นด้วยตัวอักษรหรือไม่
'' @parameter คำอธิบาย: -str [สตริง]: สตริงต้นทาง
'' @parameter คำอธิบาย: -chars [String]: การเปรียบเทียบอักขระ/สตริง
'' @return value: - [bool]
'*********************************************************** ******************************************************** ******************************************************** ******************************************************** ******************************************************** **************, ********************************************* **
ฟังก์ชั่นสาธารณะ startswith (Byval Str, Chars)
ถ้าเหลือ (str, len (chars)) = chars แล้ว
startswith = true
อื่น
startswith = false
สิ้นสุดถ้า
ฟังก์ชันสิ้นสุด
'*********************************************************** ******************************************************** ******************************************************** ******************************************************** ******************************************************** **************, ********************************************* **
'' @function คำอธิบาย: ตรวจสอบว่าสตริงต้นทางจะลงท้ายด้วยตัวอักษร
'' @parameter คำอธิบาย: -str [สตริง]: สตริงต้นทาง
'' @parameter คำอธิบาย: -chars [String]: การเปรียบเทียบอักขระ/สตริง
'' @return value: - [bool]
'*********************************************************** ******************************************************** ******************************************************** ******************************************************** ******************************************************** **************, ********************************************* **
ฟังก์ชั่นสาธารณะ Endswith (Byval Str, Chars)
ถ้าถูกต้อง (str, len (chars)) = chars แล้ว
endswith = true
อื่น
endswith = false
สิ้นสุดถ้า
ฟังก์ชันสิ้นสุด
'*********************************************************** ******************************************************** ******************************************************** ******************************************************** ******************************************************** **************, ********************************************* **
'' @function คำอธิบาย: คัดลอก n สตริง str
'' @parameter คำอธิบาย: -str [สตริง]: สตริงต้นทาง
'' @parameter คำอธิบาย: -n [int]: จำนวนแบบจำลอง
'' @return value: - [สตริง] คัดลอกสตริง
'*********************************************************** ******************************************************** ******************************************************** ******************************************************** ******************************************************** **************, ********************************************* **
ฟังก์ชั่นสาธารณะโคลน (Byval Str, N)
สำหรับ i = 1 ถึง n
value = value & str
ต่อไป
โคลน = ค่า
ฟังก์ชันสิ้นสุด
'*********************************************************** ******************************************************** ******************************************************** ******************************************************** ******************************************************** **************, ***************
-สถานีดาวน์โหลดแหล่งข้อมูลแหล่งที่มาที่ใหญ่ที่สุดของเว็บไซต์
-'' @function คำอธิบาย: ลบอักขระ n ด้านหน้าของสตริงต้นทาง str
'' @parameter คำอธิบาย: -str [สตริง]: สตริงต้นทาง
'' @parameter คำอธิบาย: -n [int]: จำนวนอักขระที่ถูกลบ
'' @return value: - [String] String ที่ถูกลบ
'*********************************************************** ******************************************************** ******************************************************** ******************************************************** ******************************************************** **************, ********************************************* **
ฟังก์ชั่นสาธารณะ TrimStart (Byval Str, N)
value = mid (str, n+1)
trimStart = ค่า
ฟังก์ชันสิ้นสุด
'*********************************************************** ******************************************************** ******************************************************** ******************************************************** ******************************************************** **************, ********************************************* **
'' @function คำอธิบาย: ลบสตริง N สุดท้ายของสตริงต้นทาง
'' @parameter คำอธิบาย: -str [สตริง]: สตริงต้นทาง
'' @parameter คำอธิบาย: -n [int]: จำนวนอักขระที่ถูกลบ
'' @return value: - [String] String ที่ถูกลบ
'*********************************************************** ******************************************************** ******************************************************** ******************************************************** ******************************************************** **************, ********************************************* **
Trimend ฟังก์ชั่นสาธารณะ (Byval Str, N)
ค่า = ซ้าย (str, len (str) -n))
trimend = ค่า
ฟังก์ชันสิ้นสุด
'*********************************************************** ******************************************************** ******************************************************** ******************************************************** ******************************************************** **************, ********************************************* **
'' @function คำอธิบาย: ตรวจสอบว่าตัวละครเป็นตัวละครภาษาอังกฤษ AZ หรือ AZ
'' @parameter คำอธิบาย: -character [Char]: ตัวละครตรวจสอบ
'' @return value: - [bool] ถ้ามันเป็นอักขระภาษาอังกฤษกลับมาจริงหรือเท็จมิฉะนั้นเท็จ
'*********************************************************** ******************************************************** ******************************************************** ******************************************************** ******************************************************** **************, ********************************************* **
ฟังก์ชั่นสาธารณะ
asciivalue = cint (asc (อักขระ))
ถ้า (65 <= asciivalue และ asciivalue <= 90) หรือ (97 <= asciivalue และ asciivalue <= 122) จากนั้น
isalphabetic = true
อื่น
isalphabetic = false
สิ้นสุดถ้า
ฟังก์ชันสิ้นสุด
'*********************************************************** ******************************************************** ******************************************************** ******************************************************** ******************************************************** **************, ********************************************* **
'' @Function หมายเหตุ: ดำเนินการแปลงตัวพิมพ์เล็กของสตริง STR
'' @parameter คำอธิบาย: -str [สตริง]: สตริงต้นทาง
'' @return value: - [String] สตริงที่แปลงแล้ว
'*********************************************************** ******************************************************** ******************************************************** ******************************************************** ******************************************************** **************, ********************************************* **
ฟังก์ชั่นสาธารณะ swapcase (STR)
สำหรับ i = 1 ถึง len (str)
current = mid (str, i, 1)
ถ้า isalphabetic (ปัจจุบัน) แล้ว
สูง = ASC (UCASE (ปัจจุบัน))
low = asc (lcase (ปัจจุบัน))
ผลรวม = สูง + ต่ำ
return = return & chr (sum-asc (ปัจจุบัน))
อื่น
return = return & current
สิ้นสุดถ้า
ต่อไป
swapcase = return
ฟังก์ชันสิ้นสุด
'*********************************************************** ******************************************************** ******************************************************** ******************************************************** ******************************************************** **************, ********************************************* **
'' @function คำอธิบาย: แปลงตัวอักษรตัวแรกของแต่ละคำในสตริงต้นทาง str เป็นตัวพิมพ์ใหญ่
'' @parameter คำอธิบาย: -str [สตริง]: สตริงต้นทาง
'' @return value: - [String] สตริงที่แปลงแล้ว
'*********************************************************** ******************************************************** ******************************************************** ******************************************************** ******************************************************** **************, ********************************************* **
ฟังก์ชั่นสาธารณะใช้ประโยชน์ (STR)
Words = split (str,)
สำหรับ i = 0 ถึง Ubound (คำ)
ถ้าไม่ฉัน = 0 แล้ว
tmp =
สิ้นสุดถ้า
tmp = tmp & ucase (ซ้าย (คำ (i), 1)) & ขวา (คำ (i), len (คำ (i))-1)
คำ (i) = tmp
ต่อไป
พิมพ์ใหญ่ = arrayTring (คำ)
ฟังก์ชันสิ้นสุด
ชั้นเรียนจบ
-