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·2024-09-30 06:59
Updated·2024-10-04 09:35
Flavor·Python

r"
(?: (?<!\S)@ # Match "@" only if it's not preceded by a non-whitespace character | # OR (?: # Telegram link types reference: https://core.telegram.org/api/links # (?:https?://)? # Optional HTTP or HTTPS protocol (?:www\.)? # www subdomain (?:t\.me|telegram\.(?:me|dog)) # Match "t.me", "telegram.me", or "telegram.dog" domains / # Ensure a forward slash after the domain | # OR tg://resolve\?domain= # Match Telegram deep link schema (tg://resolve?domain=) ) | # OR (?=\b # Positive lookahead: Ensure a valid subdomain before username (?!\w*__) # Disallow double underscores anywhere in the username (?!\w*_{2,}) # Disallow underscores at the start or end of username (?:[a-z][a-z0-9_]{3,31}) # Username (?<!_) # Disallow usernames ending with an underscore \.t\.me$ # Ensure it ends with ".t.me" ) ) (?P<username> # Start capturing the username (?!\w*_{2,}) # Disallow double underscores in the username (?!\w*[^0-9a-z_.,\s]) # Ensure valid characters (letters, numbers, underscores, dots, commas, spaces) (?:[a-z][a-z0-9_]{3,31}) # Username (?<!_) # Disallow username ending with an underscore \b # Ensure it's a valid word boundary ) (?:\.t\.me)? # Optional ".t.me" subdomain
"
gmix
Open regex in editor

Description

Validates and obtains the Telegram user's username according to the rules for creating usernames

Submitted by okineadev