Community Patterns

1

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

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

gamgamtest_matei_überwiegend_version2

Created·2025-11-21 07:37
Flavor·PCRE2 (PHP)
Tier Verwalter setName($name); $this->setAlter($alter); $this->setGewicht($gewicht); $this->setGeburtsdatum($geburtsdatum); $this->setArt($art); $this->id = uniqid(); } // Getter und Setter für name public function setName($name) { $this->name = $name; } public function getName() { return $this->name; } // Getter und Setter für alter public function setAlter($alter) { $this->alter = $alter; } public function getAlter() { return $this->alter; } // Getter und Setter für gewicht public function setGewicht($gewicht) { $this->gewicht = $gewicht; } public function getGewicht() { return $this->gewicht; } // Getter und Setter für geburtsdatum public function setGeburtsdatum($geburtsdatum) { $this->geburtsdatum = $geburtsdatum; } public function getGeburtsdatum() { return $this->geburtsdatum; } // Getter und Setter für art public function setArt($art) { $this->art = $art; } public function getArt() { return $this->art; } public function getId() { return $this->id; } } if (isset($_POST'speichern'])) { $neuesTier = new Tier( $_POST['name'], $_POST['alter'], $_POST['gewicht'], $_POST['geburtsdatum'], $_POST['art'] ); if (!isset($_SESSION['tiere'])) { $_SESSION['tiere'] = array(); } $_SESSION['tiere'] = $neuesTier; } if (isset($_POST['loeschen'])) { if (isset($_SESSION['tiere'])) { unset($_SESSION['tiere']); $_SESSION['tiere'] = array(); } } ?> Neues Tier hinzufügen Name: Alter: Gewicht (kg): Geburtsdatum: Art: Speichern Alle löschen Gespeicherte Tiere: 0) { foreach ($_SESSION['tiere'] as $tier) { echo "Tier: " . htmlspecialchars($tier->getName()) . ""; } } else { echo "Keine Tiere gespeichert."; } ?>
Submitted by anonymous
1

gamgamtestplf grundlegend

Created·2025-11-21 07:37
Flavor·PCRE2 (PHP)
setName($name); $this->setPrice($price); $this->setCategory($category); } // Getter und Setter public function getName(): string { return $this->name; } public function setName(string $name): void { $this->name = trim($name); } public function getPrice(): float { return $this->price; } public function setPrice(float $price): void { // einfache Validierung, minimum 0 if ($price price = $price; } public function getCategory(): string { return $this->category; } public function setCategory(string $category): void { $this->category = trim($category); } } // ---------- FORMULAR-AKTIONEN ---------- if ($_SERVER'REQUEST_METHOD'] === 'POST') { // Aktion unterscheiden: speichern oder alles löschen $action = $_POST['action'] ?? 'save'; if ($action === 'clear') { // Alle löschen $_SESSION['products'] = []; } else { // Speichern $name = $_POST['name'] ?? ''; $priceRaw = $_POST['price'] ?? '0'; $category = $_POST['category'] ?? ''; // number-Input kommt als String, in float wandeln $price = (float) str_replace(',', '.', $priceRaw); // Neues Objekt der Basisklasse erzeugen $product = new Product($name, $price, $category); // In Session-Array speichern, Key = uniqid() $id = uniqid('p_', true); $_SESSION['products' = $product; } // Optional: Redirect, um Formular-Resubmits zu vermeiden header('Location: ' . $_SERVER['PHP_SELF']); exit; } ?> Product Webapp body { font-family: Arial, sans-serif; margin: 20px; } form { margin-bottom: 20px; } label { display: block; margin-top: 10px; } input, select { padding: 5px; width: 250px; max-width: 100%; } button { margin-top: 15px; padding: 6px 12px; cursor: pointer; } table { border-collapse: collapse; margin-top: 20px; width: 100%; max-width: 600px; } th, td { border: 1px solid #ccc; padding: 8px; } th { background: #eee; } Produktverwaltung (Session-Demo) Produktname (type="text") Preis in € (type="number") Kategorie Elektronik Haushalt Bücher Sonstiges Speichern Alle löschen Gespeicherte Produkte (nur ein Feld wird ausgegeben) Produktname (eine Membervariable) $product): ?> getName(), ENT_QUOTES, 'UTF-8'); ?> Aktuell sind keine Produkte in der Session gespeichert.
Submitted by anonymous

Community Library Entry

83

Regular Expression
Created·2014-06-26 09:59
Updated·2023-07-20 15:08
Flavor·Python

r"
^ # get the title of this movie or series (?P<title> [-\w'\"]+ # match separator to later replace into correct title (?P<separator> [ .] ) # note this *must* be lazy for the engine to work ltr not rtl (?: [-\w'\"]+\2 )*? ) # start of movie vs serie check (?: # if this is an episode, lets match the season # number one way or another. if not, the year # of the movie (?: # series. can be a lot prettier if we used perl regex... # make sure this is not just a number in the title followed by our separator. # like, iron man 3 2013 or my.fictional.24.series (?! \d+ \2 ) # now try to match the season number (?: s (?: eason \2? )? )? (?P<season> \d\d? ) # needed to validate the last token is a dot, or whatever. (?: e\d\d? (?:-e?\d\d?)? | x\d\d? )? | # this is likely a movie, match the year (?P<year> [(\]]?\d{4}[)\]]? ) ) # make sure this ends with the separator, otherwise we # might be in the middle of something like "1080p" (?=\2) | # if we get here, this is likely still a movie. # match until one of the keywords (?= BOXSET | XVID | DIVX | LIMITED | UNRATED | PROPER | DTS | AC3 | AAC | BLU[ -]?RAY | HD(?:TV|DVD) | (?:DVD|B[DR]|WEB)RIP | \d+p | [hx]\.?264 ) )
"
gimx
Open regex in editor

Description

A neat regex for finding out whether a given torrent name is a series or a movie.

Returns the full name of the series with the separator needed to make it pretty (ie, replace it with space or what you want). Also returns the season number or the year for the movie/series, depending on what was previously matched.

Submitted by Firas Dib