ต่อไปนี้เป็นซอร์สโค้ดของฟังก์ชัน:
-
ฟังก์ชั่น Takeout (รูปแบบ, string1, สี)
'แยกข้อความที่ตรงกับคำค้นหา
Dim regEx, Match, Matches, tt 'สร้างตัวแปร
ตั้งค่า regEx = New RegExp ' สร้างนิพจน์ทั่วไป
regEx.Pattern = patrn ' กำหนดรูปแบบ
regEx.IgnoreCase = True ' ตั้งค่าว่าจะคำนึงถึงตัวพิมพ์เล็กและตัวพิมพ์ใหญ่หรือไม่
regEx.Global = True ' ตั้งค่าความพร้อมใช้งานทั่วโลก
Set Matches = regEx.Execute(string1) 'ดำเนินการค้นหา
สำหรับการแข่งขันแต่ละรายการในแมตช์ ' สำรวจคอลเลกชันแมตช์
RetStr = RetStr & Match.Value &
ต่อไป
RetStr = เล็ม (RetStr)
ถ้า instr(RetStr, )>0 แล้ว
สำหรับ tt = 0 ถึง ubound (แยก (RetStr, ))
string1 = แทนที่(string1,แยก(RetStr, )(tt),<font color=&colors&>&split(RetStr, )(tt)&</font>)
ต่อไป
อื่น
string1 = แทนที่(string1,RetStr,<font color=&colors&>&RetStr&</font>)
สิ้นสุดถ้า
ซื้อกลับบ้าน = string1
ฟังก์ชันสิ้นสุด
response.write Takeout (jOeKOe, รุ่นสองภาษา Joekoe, สีแดง)
Function Highlight(strContent,keyword) 'ทำเครื่องหมายคำสำคัญที่เน้นสี
Dim RegEx
ตั้งค่า RegEx=regExp ใหม่
RegEx.IgnoreCase =True 'ไม่คำนึงถึงขนาดตัวพิมพ์
RegEx.Global=จริง
Dim ArrayKeyword,i
ArrayKeyword = Split(keyword, ) 'คำหลักหลายคำคั่นด้วยช่องว่าง
สำหรับ i=0 ถึง Ubound (ArrayKeyword)
RegEx.Pattern=(&ArrayKeyword(i)&)
strContent=RegEx.Replace(strContent,<font color=red>$1</font> )
ต่อไป
ตั้งค่า RegEx=ไม่มีอะไร
ไฮไลท์=strContent
ฟังก์ชันสิ้นสุด
response.write Highlight(เวอร์ชันสองภาษา Joekoe, jOeKOe)
-
-