REGEXP (Regular Expression Function) เริ่มมีใน Oracle Database 10g ทำหน้าที่ค้นหารูปแบบตัวอักษรที่อยู่ในข้อมูล ซึ่งมีด้วยกัน 4 Function REGEXP_LIKE , REGEXP_INSTR, REGEXP_SUBSTR, REGEXP_REPLACE
ขณะที่ Version 11g เพิ่มมาอีก 1 Function คือ REGEXP_COUNT คือ นับจำนวนครั้งของรูปแบบอักษรที่ค้่นหา
คราวนี้ ผม Reveiw เฉพาะ REGEXP_COUNT อย่างเดียวก่อน ไว้ว่างจะร่ายยาวการใช้งานของที่เหลืออีกทีนะครับ
ตัวอย่าง SQL> SELECT REGEXP_COUNT ('Oracle Database PL/SQL New Feature Cooldb.net Oracle Tutorial in THAI','ora',1,'i') REG_COUNT FROM DUAL ; REG_COUNT 2 อธิบาย ตัวอย่างการหาคำว่า ora จากประโยค Oracle Database PL/SQL New Feature Cooldb.net Oracle Tutorial in THAI เีริ่มหาตั้งแต่ตัวแรก โดยไม่สนใจ Case Sensitive จะเจอ 2 ครั้ง คือ Oracle Database PL/SQL New Feature Cooldb.net Oracle Tutorial in THAI Parameter ที่ใช้ Data,Search Pattern,ตำแหน่งเริ่มต้นค้นหา , Match option Data = Oracle Database PL/SQL New Feature Cooldb.net Oracle Tutorial in THAISearch Pattern = ora
ตำแหน่งเริ่มต้นค้นหา = 1
Match option = i (incase sensitive)
Match Option อื่นๆ ได้แ้ก่ c = Case sensitive , n = allow period , m = allow multiple line , x = ignore white space
|