Use when adding new error messages to React, or seeing "unknown error code" warnings.
npx skills add vuralserhat86/antigravity-agentic-skills --skill "regex_builder"
Install specific skill from multi-skill repository
# Description
Regular expression oluşturma, test etme, debug ve açıklama rehberi.
# SKILL.md
name: regex_builder
router_kit: FullStackKit
description: Regular expression oluşturma, test etme, debug ve açıklama rehberi.
metadata:
skillport:
category: development
tags: [accessibility, api integration, backend, browser apis, client-side, components, css3, debugging, deployment, frameworks, frontend, fullstack, html5, javascript, libraries, node.js, npm, performance optimization, regex builder, responsive design, seo, state management, testing, typescript, ui/ux, web development] - text-processing
🔤 Regex Builder
Regular expression oluşturma ve test rehberi.
📋 Temel Syntax
Karakter Sınıfları
| Pattern | Eşleşir | Örnek |
|---|---|---|
. |
Herhangi karakter | a.c → "abc", "a1c" |
\d |
Rakam [0-9] | \d+ → "123" |
\w |
Word char [a-zA-Z0-9_] | \w+ → "hello_123" |
\s |
Whitespace | a\sb → "a b" |
\D |
Rakam değil | \D+ → "abc" |
\W |
Word char değil | \W+ → "!@#" |
Quantifiers
| Pattern | Anlam | Örnek |
|---|---|---|
* |
0 veya daha fazla | ab*c → "ac", "abc", "abbc" |
+ |
1 veya daha fazla | ab+c → "abc", "abbc" |
? |
0 veya 1 | ab?c → "ac", "abc" |
{n} |
Tam n kere | a{3} → "aaa" |
{n,m} |
n ile m arası | a{2,4} → "aa", "aaa", "aaaa" |
{n,} |
En az n | a{2,} → "aa", "aaa", ... |
Anchors
| Pattern | Anlam |
|---|---|
^ |
Satır başı |
$ |
Satır sonu |
\b |
Word boundary |
\B |
Non-word boundary |
🔧 Yaygın Patterns
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
URL
https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)
Telefon (TR)
^(\+90|0)?[0-9]{10}$
IP Address
^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}$
Date (YYYY-MM-DD)
^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$
Password (Strong)
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$
🧪 Test Komutları
JavaScript
const regex = /pattern/flags;
regex.test('string'); // true/false
'string'.match(regex); // matches array
'string'.replace(regex, 'replacement');
Python
import re
re.search(r'pattern', 'string')
re.findall(r'pattern', 'string')
re.sub(r'pattern', 'replacement', 'string')
CLI (ripgrep)
rg 'pattern' file.txt
rg -o 'pattern' file.txt # Only matching
rg -c 'pattern' file.txt # Count
🔍 Debugging Tips
- Escape special chars:
. * + ? ^ $ { } [ ] ( ) | \ - Lazy vs Greedy:
.*?(lazy) vs.*(greedy) - Non-capturing group:
(?:pattern) - Lookahead:
(?=pattern)ve(?!pattern) - Lookbehind:
(?<=pattern)ve(?<!pattern)
Regex Builder v1.1 - Enhanced
🔄 Workflow
Aşama 1: Construction & Security
- [ ] Named Groups:
(?<year>\d{4})gibi isimlendirilmiş gruplar kullan (Okunabilirlik). - [ ] ReDoS Prevention: "Catastrophic Backtracking"i önlemek için Atomic Groups
(?>...)veya Possessive Quantifiers++kullan. - [ ] Boundaries: Her zaman
^ve$(veya\Ave\z) ile string sınırlarını belirle.
Aşama 2: Testing & Validation
- [ ] Visual Testing: Regex101 veya RegExr üzerinde görsel olarak test et.
- [ ] Unit Tests: Hem "match" (pozitif) hem "non-match" (negatif) case'lerini test et.
- [ ] Performance: Regex'in çalışma süresini limitli tut (Execution timeout).
Aşama 3: Implementation
- [ ] Pre-compilation: Döngü içinde regex derleme (
new RegExp,re.compile). Başlangıçta derle. - [ ] Comments: Karmaşık regex'ler için
(?# comment)veya "Verbose Mode" (Pythonre.X) kullan. - [ ] Library: Çok karmaşık patternler için hazır kütüphaneleri (URL parser, Email validator) tercih et, tekerleği yeniden icat etme.
Kontrol Noktaları
| Aşama | Doğrulama |
|---|---|
| 1 | Regex ReDoS saldırısına karşı güvenli mi? (Safe-regex toolları ile tara). |
| 2 | Pattern sadece beklenen karakterleri mi kabul ediyor? (Allowlist vs Blocklist). |
| 3 | Unicode desteği (u flag) açık mı? (Emoji ve UTF-8 karakterler için). |
# Supported AI Coding Agents
This skill is compatible with the SKILL.md standard and works with all major AI coding agents:
Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.