Regular Expressions 101

Community Patterns

1

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

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

Regex for Matching Documentation Websites

Created·2024-11-24 01:45
Flavor·ECMAScript (JavaScript)
Regex for Matching Documentation Websites This repository contains a powerful regular expression designed to match URLs that commonly point to documentation-related websites. The regex is optimized for flexibility, covering various terms and URL patterns. Regex Pattern ^.(?:\.|\/)(docs|documentation|help|guide|manual|reference|api|kb|support|resources|wiki|developer|how-to|tutorials|examples|learn|instructions)(?:\.|\/)?.$ Purpose This regex is intended to identify URLs that contain keywords associated with documentation or support websites. It handles common patterns in subdomains, directories, and file paths. Explanation ^.*: Matches any characters at the beginning of the URL (any prefix). (?:\.|\/): Matches either a period (.) or a forward slash (/) preceding the keyword. (docs|documentation|help|guide|manual|...): Matches any of the keywords listed in the group. (?:\.|\/)?: Allows an optional period (.) or forward slash (/) following the keyword. .*$: Matches any characters following the keyword (any suffix). Examples Positive Examples The following URLs should match the regex: https://example.com/docs http://docs.example.com https://example.com/documentation https://sub.domain.com/docs/index.html https://example.com/help https://api.example.com/docs http://example.com/manual/index.html https://wiki.example.com http://developer.example.com/guide https://example.com/tutorials/docs/page https://kb.example.com/docs/tutorial.html https://example.com/resources/documentation/tutorial.html http://example.com/reference/help/documentation.html https://developer.example.com/docs/tutorials/index.html http://support.example.com/documentation/overview https://resources.example.com/docs/v1/tutorial https://example.com/how-to/documentation http://example.com/api/reference/docs https://example.com/reference/v2/index.html http://example.com/docs/resources/api.html Negative Examples The following URLs should not match the regex: https://example.com/documentary http://helpful.example.com https://manuals.example.com http://example.com/references https://example.com/resourceful http://example.com/wiki-books https://apiary.example.com http://example.com/documents http://example.com/documentable https://help-center.example.com http://manual.example.com/docsystem https://example.com/resourcesful http://api.example.comary https://example.net/instructions-v1 http://example.org/learned-tutorial http://example.com/support-center Author Jeremy Georges-Filteau Website Github
Submitted by jgeofil

Community Library Entry

1

Regular Expression
Created·2017-08-01 12:16
Flavor·PCRE (Legacy)

/
^[A](([A-Z]|[0-9])?([A-Z]|[0-9])?([A-Z]|[0-9]))\s[0-9][A-Z][A-Z]$
/
gm
Open regex in editor

Description

Saudi Postal Code has five digits, if you would to have more information check the below: +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

First Digit (Postal Regions): "The postal region number is represented by the first digit of the postal code"

The kingdom is divided into 8 postal regions. The division was based on the country's administrative regions. The numbering of the postal regions differs from that of the administrative regions in the kingdom. The Postal Division was based on the consideration of road connectivity network and other geographical factors. The below table shows the list of Postal Regions in the country: 1 Arriyadh Region 2 Makkah Region 3 Eastern Provience Region 4 Madinah and Tabuk 5 Qassim and Ha'il 6 Asir, Najran, and Bahah 7 Northern Borders, and Jawf 8 Jizan


Second Digit (Postal Sectors): "The postal sector number is represented by the second digit of the postal code"

Each postal region is divided into postal sectors (each region consists of maximum 8 sectors). Sectors are numbered starting from 2 to 9; number (1) is excluded for government and exceptional services usage. Sectors are divided according to the following basis: The center of the region, which is usually its capital, is assigned the first number of sector numbers. Sectors to the south of the center are assigned even numbers. Sectors to the north of the center are assigned odd numbers. Upon dividing sectors, the following was taken into consideration: The borders of provinces' domains within any postal region. Terrain and geographical factors, such as: mountains, plains, valleys between provinces. Economic costs resulting from providing postal and logistic services. Population distribution and density inside the sectors.


Third Digit (Postal Branches): "The postal branch number is represented by the third digit of the postal code"

Each postal sector is divided into many postal branches, with maximum of 8 branches for each sector. Number (1) is excluded for governmental and exceptional services usage. Upon dividing branches, it was taken into consideration that their borders should be highways or main roads as much as possible. There are 3 distinct strategies when dividing Postal branches.


Fourth Digit (Postal Divisions): "The postal division number is represented by the fourth digit of the postal code"

Postal branches are divided into many divisions, each branch consists of maximum number of nine divisions. Divisions are almost equally divided. Areas of divisions may differ due to the following reasons:

1)Geographical and terrain factors between postal divisions. 2)Density of population in a given division. 3)Divisions of any branch are divided according to main roads and streets, and interconnecting streets, according to street categories. 4)Coding of postal divisions is based upon the nearest division to the axis of the division, where smaller numbers are assigned to postal divisions which are the closest to the axis lines. The numbers increase as we move far from the axis.


Fifth Digit (Postal Squares): "The postal square number is represented by the fifth digit of the postal code"

Each postal section is divided into squares. The area of each square should not be more than 4x4 km². Squares were divided according on the following basis:

1)Considering that no square should exceed 4x4 km². 2)Squares within low-density urban zones should be about 2x2 km². 3)Squares within high-density and populated urbban zones should be about 1x1 km². 4)Squares divisions are based on the network of main and side roads and streets, according to the nearest to the branch axis. The smallest number is assigned to square that are nearest to the axis. Square numbers increase ascendingly as we move far from the axis.


Submitted by Fares Alarabi