Regular Expressions 101

Community Patterns

1

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

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

Community Library Entry

0

Regular Expression
Created·2018-12-19 16:59
Flavor·PCRE (Legacy)

/
^ # Start of version string \s* # Ignore leading whitespace (?:v\.?)? # Optional "v" or "v." before the version (?<major>\d+) \. (?<minor>\d+) \. (?<patch>\d+) # MAJOR.MINOR.PATCH (?:- # Pre-release versions start with '-' (?<pre> # Capture the pre-release identifier(s) (?: # The PR rules are annoyingly tight [0-9A-Za-z-] # No leading `0`, but a `0` on its own is fine | # More than one character... [1-9A-Za-z-][0-9A-Za-z-]* # ...means no leading zero ) # That's the FIRST pre-release identifier (?: # Multiple are allowed... \. # ...dot-separated... (?: # ...with the same rules as above [0-9A-Za-z-] | [1-9A-Za-z-][0-9A-Za-z-]* ) )* # Of course, you can also have just the one ) # End name-cap group `pre` )? # End non-cap group encompassing the leading `-` and the identifiers (?: # Built metadata is SIMILAR, but with two differences: \+ # Difference one: starts with `+` (?<meta> [0-9A-Za-z-]+ # Difference two: leading `0` is allowed, so the match rule is simpler (?:\.[0-9A-Za-z-]+)* # Same dot-delim repetition ) # End name-cap group `meta` )? # End non-cap group encompassing leading `+` and identifiers \s* # Ignore trailing whitespace $ # End version string
/
gmix
Open regex in editor

Description

Implements PCRE named-capture (with comments) for the Semantic Versioning 2.0.0 standard - processing is left an exercise for the reader ;)

Submitted by anonymous