التعبيرات النمطية في 5 دقائق
الثوابت والفئات ومحددات الكمية
التعبيرات النمطية في 5 دقائق درس مجاني في NLP Academy على CoddyKit. هذا هو الدرس 1 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في NLP Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة NLP Academy 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
A Tiny Language for Patterns
A regular expression is a tiny pattern language for matching text. Instead of one fixed word, you describe the shape of what you want to find.
Python Speaks Regex Too
Python uses the built-in re module for regex. Import it once and you can search, match, and extract patterns from any string.
import re
re.search("cat", "the cat sat")Literals: Exact Characters
The simplest pattern is a literal. The pattern dog matches the exact letters d, o, g, in that order, wherever they appear in your text.
search Finds the First Match
Use re.search to scan a string and return the first place your pattern appears, or None when nothing matches at all.
m = re.search("sat", "the cat sat")
print(m.group())Character Classes With Brackets
A character class in square brackets matches any one listed character. The pattern [abc] matches a single a, b, or c each time.
re.findall("[aeiou]", "hello")Handy Class Shortcuts
Some classes have shortcuts. \d matches any digit, \w matches word characters, and \s matches spaces. They save you a lot of typing. 😊
The Dot Matches Anything
The dot stands for any single character except a newline. So h.t matches hat, hit, and hot, but never the two-letter ht.
Quantifiers Repeat Patterns
A quantifier says how many times the part before it repeats. Add a plus for one or more, a star for zero or more.
re.findall("a+", "aaa banana")Exact Counts With Braces
Use braces for precise repetition. The pattern \d{3} matches exactly three digits in a row, perfect for area codes or short IDs.
re.findall("\d{3}", "call 911 now")Anchors Pin the Position
Anchors match a position, not a character. The caret means start of string and the dollar sign means end of string.
findall Returns Every Match
While search finds one match, re.findall returns a list of every match in the text, which is great for counting or extracting many items.
re.findall("\d+", "2 cats, 5 dogs")Quick Check
You want to match exactly three digits in a row. Which pattern fits?
Recap: Your Regex Toolkit
You met literals, classes, the dot, quantifiers, and anchors. With re.search and re.findall, you can already describe and find real patterns. 🎉
الأسئلة الشائعة
هل درس «التعبيرات النمطية في 5 دقائق» مجاني؟
نعم — نص درس «التعبيرات النمطية في 5 دقائق» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة NLP Academy، انتقل إلى CoddyKit PRO. تتضمن دورة NLP Academy 4 دروس في المجموع.
ماذا ستتعلم في «التعبيرات النمطية في 5 دقائق»؟
الثوابت والفئات ومحددات الكمية تتمرن على NLP Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ NLP Academy؟
لا تُشترط خبرة سابقة. NLP Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 1 من أصل 4.
كم من الوقت يستغرق درس «التعبيرات النمطية في 5 دقائق»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس NLP Academy هذا؟
نعم. كل درس في NLP Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- التعبيرات النمطية في 5 دقائق
- العثور على عناوين البريد الإلكتروني وعناوين URL
- مجموعات الالتقاط والاستبدالات
- حيل تقسيم النص بالـ Regex