Regex Tester - اختبار التعبيرات النمطية أونلاين
اختبار وتصحيح Regular Expressions مع تمييز التطابق ودعم flags.
Keywords
regex tester, اختبار regex, pattern matcher
تساعدك أداة Regex Tester على تصميم واختبار تعبيرات Regular Expressions مع نتائج فورية. استخدمها للتحقق من البريد الإلكتروني، واستخراج المعرفات، وتنظيف النصوص، وتحليل السجلات.
أساسيات Regex
يتكون Regex من أحرف عادية ومحارف خاصة. النقطة (.) تطابق أي حرف، ^ و $ يحددان البداية والنهاية، * + ? {m,n} تحدد التكرار، [a-z] و\d و\w تمثل فئات أحرف، و( ) تُستخدم للتجميع. يمكن استخدام الأعلام مثل g وi وm وs وu لتعديل سلوك البحث.
أنماط عملية جاهزة
مثال بريد إلكتروني بسيط: ^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$. مثال تاريخ ISO: ^\d{4}-\d{2}-\d{2}$. استخدمها كنقطة انطلاق وعدّلها حسب احتياجات مشروعك.
خطوات البناء
ابدأ بنص حقيقي، ثم أضف الأنماط تدريجيًا. استخدم المجموعات لاستخراج أجزاء محددة، واختبر النتائج مع أمثلة متعددة.
Boundaries, lookarounds, and Unicode
Word boundaries (\b) are handy, but not all engines treat them as Unicode‑aware. Use the u flag where supported and prefer explicit classes when working with international text. Lookaheads (?=...) and lookbehinds (?<=...) assert context without consuming characters—great for matching digits only when preceded by a currency symbol, or extracting a slug only when it follows a known prefix. Many engines support lookaheads widely; lookbehinds can be missing in older runtimes, so verify in your target environment.
Performance and catastrophic backtracking
Nested, ambiguous quantifiers can cause catastrophic backtracking, where the engine tries exponential paths before failing. Classic footguns include patterns like (a+)+ on long strings, or (.*)+ combined with alternation. To keep regexes fast: (1) be specific with character classes, (2) avoid nested star/plus quantifiers, (3) prefer atomic groups (?>...) or possessive quantifiers where available, and (4) anchor patterns to reduce search space. Test with large worst‑case strings in the tester to surface slow cases before production.
Search‑and‑replace safely
For rewrite jobs, test capture groups and backreferences thoroughly. For example, to swap last and first name in 'Doe, Jane', use ^([^,]+),\s*(.+)$ with replacement $2 $1. When replacing in code, escape replacement strings correctly—different languages treat $1, \1, or named groups differently. For multi‑line edits, enable the multiline flag and use explicit anchors for lines (^) and ($). Always keep a backup of original text for bulk operations.
Testing strategy and maintainability
Treat regexes as code: write a few representative positive and negative examples, add them to unit tests where patterns are critical, and comment tricky parts. Prefer clarity over cleverness—longer but explicit classes often outperform terse, ambiguous constructs. If a pattern encodes business rules (for example, product SKU formats), document the intent alongside the expression so future maintainers can update it safely.
Use the regex tester to iterate safely, document patterns with concrete examples, and keep expressions as simple and specific as possible. Favor clear character classes, anchored searches, and measured use of lookarounds to balance correctness with speed.
regex tester
الاختبار ، المطابقة ، استبدال ، وتقسيم النص باستخدام التعبيرات العادية مع التحقق من صحة الوقت الحقيقي
نمط التعبير العادي
سلسلة اختبار
نتيجة
Regex مرجع سريع
فصول الشخصية
\\d - Digits (0-9)\\w - Word characters\\s - Whitespace. - Any characterالكميات
* - 0 or more+ - 1 or more? - 0 or 1{n,m} - Between n and mالمراسي
^ - Start of string$ - End of string\\b - Word boundary\\B - Non-word boundary