مختبر Regex
رائج 🔥اختبار التعبيرات النمطية مباشرة
كيفية استخدام مختبر Regex
- 1أدخل التعبير النمطي في الحقل العلوي
- 2اكتب النص الاختباري في منطقة النص
- 3تُظلَّل التطابقات فورًا
- 4راجع شرح بنية التعبير
حول مختبر Regex
مختبر Regex هو أداة تفاعلية لكتابة واختبار وتصحيح التعبيرات النمطية (Regular Expressions) في الوقت الحقيقي. يُظهر التطابقات ملوّنة ويشرح بنية التعبير ويدعم جميع أعلام Regex القياسية.
المميزات الرئيسية لـ مختبر Regex
- تظليل التطابقات في الوقت الحقيقي
- دعم أعلام g، i، m، s، u
- شرح بنية التعبير
- عرض مجموعات الالتقاط
- مكتبة أنماط شائعة
- Works entirely in-browser using JavaScript RegExp
- Pattern explanation sidebar to understand each part of the regex
- Compatible with Node.js and all major JavaScript runtimes
أمثلة
التحقق من البريد الإلكتروني
نمط أساسي للتحقق من البريد الإلكتروني
المدخلات
^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,}$النتيجة
يتطابق مع: user@example.com
Extract all URLs from a block of text
Use a global pattern to find all HTTP/HTTPS URLs in a text string.
المدخلات
Pattern: https?://[^\s]+ (with g flag) | Test: text containing multiple URLs
النتيجة
All URLs highlighted, each shown as a separate match
حالات الاستخدام الشائعة
- التحقق من صحة الإدخال
- استخراج البيانات من النصوص
- معالجة ملفات السجل
- البحث والاستبدال المتقدم
- تعلم التعبيرات النمطية
- Extracting specific fields from structured text like CSV rows or configuration lines
استكشاف الأخطاء
تعبير لا يتطابق أبدًا
الحل
تحقق من الأعلام — قد تحتاج i للتجاهل حالة الأحرف أو g لجميع التطابقات
أداء بطيء (Catastrophic Backtracking)
الحل
تجنب التداخل المتشعب مثل (a+)+ — أعد كتابة التعبير بشكل أكثر تحديدًا
Regex causes the browser to hang or become unresponsive
الحل
Catastrophic backtracking can occur with certain patterns on long inputs — for example, nested quantifiers like (a+)+ on a non-matching input. Simplify the pattern or test with shorter strings first.
الأسئلة الشائعة
ما الفرق بين .* و.*؟
.* يتطابق مع أي شيء (جشع)، بينما .*? يتطابق بأقل قدر ممكن (كسول).
هل تدعم Regex المتوافق مع PCRE؟
الأداة تستخدم محرك JavaScript RegExp مع بعض الاختلافات الطفيفة عن PCRE.
How do I match a newline?
Use \n to match a newline character in the pattern. If you want . to match newlines as well as other characters, enable the dotAll (s) flag.
What are capture groups?
Capture groups are portions of a regex pattern enclosed in parentheses. They capture the matched text for each group separately. For example, (\d{4})-(\d{2})-(\d{2}) on "2023-11-14" captures "2023", "11", and "14" as three groups.
What is the difference between a greedy and lazy quantifier?
Greedy quantifiers (like +, *) match as much as possible. Lazy/non-greedy quantifiers (like +?, *?) match as little as possible. For example, .+? stops at the first match, while .+ continues to the end of the line.
Can I test patterns with Unicode characters?
Yes. Enable the unicode (u) flag to use Unicode property escapes like \p{Letter} and correctly handle surrogate pairs and characters outside the Basic Multilingual Plane.
Is my data sent to a server?
No. All regex matching is performed locally in your browser using the native JavaScript RegExp engine. Your patterns and test strings never leave your device.
Can I use this regex in other programming languages?
The JavaScript RegExp flavor is similar to but not identical to Python, Java, or PCRE regex. Lookaheads, basic quantifiers, and character classes are broadly compatible. Language-specific features (like Python's (?P<name>) syntax) will need adjustment.