Community Patterns

1

ตรวจสอบพยัญชนะต้นตัวสะกดสระและวรรณยุกต์ไทย

Created·2026-01-22 01:36
Updated·2026-01-23 12:42
Flavor·ECMAScript (JavaScript)
ตรวจสอบพยัญชนะต้น (ต้องมี) ตรวจตัวสะกดสำหรับสระที่ต้องมี ตรวจสอบการวางสระและวรรณยุกต์ไทย หมายเหตุ การตรวจสอบตัวสะกดในภาษาไทยตรวจสอบได้ยากเพราะภาษาไทยเป็นภาษาที่เขียนติด ๆ กันไม่มีการแบ่งคำอย่างชัดเจนทำให้การอ่านภาษาไทยผู้อ่านต้องใช้ความหมายของคำในการตัดสินการอ่านแบ่งคำตามความเหมาะสมเช่นคำว่า "ตากลม" อาจอ่านเป็น "ตาก-ลม" ก็ได้ หรืออ่านเป็น "ตา-กลม"ก็ได้ ดังนั้นการเขียน Regex เพื่อทำการตรวจสอบอาจช่วยได้ระดับหนึ่ง อ่าจมีผิดบ้างถูกบ้าง แต่ก็ถือว่าเป็นเครื่องมือที่ใช้ช่วยเหลือในการตรวจสอบเพิ่มเติมได้ 80% ของความเป็นไปใด้ก็แล้วกันนะครับ หวังว่าการเขียนเพิ่มเติมส่วนนี้ จะมีประโยชน์บ้างไม่มากก็น้อย
Submitted by อธิปัตย์ ล้อวงศ์งาม

Community Library Entry

1

Regular Expression
Created·2025-02-13 19:59
Flavor·PCRE2 (PHP)

/
(?i)(?=(\d)\d)(?<![\d\-\x{2013}\x{2014}%])(?!000|666|9\d\d|\d{3}00|\d{5}0000|\1{9}|012345678|123456789|234567890|098765432|876543210|078051120|219099999)\d{9}(?![\d\-\x{2013}\x{2014}%])(?!\.(?:pdf|docx?|xlsx?|pptx?|zip|jpe?g|png|txt|log)\b)
/
gm
Open regex in editor

Description

Developed for use with Microsoft Purview DLP, which uses the PCRE-compatible "Boost.Regex" engine for pattern matching.

Matches unformatted US Social Security number patterns (i.e. nine digits with no separators):

  • Exclude all-zero area, group, or serial segment sequences:
    00XXXXXX, XXX00XXXX, or XXXXX0000
  • Exclude group numbers 666 and 9##:
    666XXXXXX or 900XXXXXX
  • Exclude ascending and descending number sequences:
    123456789, 876543210, etc.
  • Excludes known retired SSNs:
    078051120 and 219099999
  • Allows dash, em-dash, en-dash, space, slash, tab, and "null" separators
  • Boundary checks to prevent matching on telephone, credit card, and other non-SSN types.
  • Excludes sequences ending with common file extensions:
    .pdf, .doc(x), .xls(x), .ppt(x), .zip, .jp(e)g, .png, and .log

Derived from: Comprehensive US SSN (Social Security Number) Also uses patterns from the "U.S. Social Security Number (SSN) (Nucleuz Inc)" Sensitive Information Type contained in the Microsoft Purview DLP tool.

Submitted by J. Greg Mackinnon