🔎

Regex

83 cards · 🇺🇸 English

Regular expression syntax: metacharacters, quantifiers, groups, and anchors.

Study all 83 cards for free

Flashcards, quizzes, pixel-art games and a daily review that remembers for you.

Study this deck free

Try the first 10 cards

1 / 10
Question

Regular expression (regex)

Knew itLearning

Tap the card for the answer · swipe right if you knew it, left if not

Already have an account? Sign in

Cards

  1. 1Regular expression (regex)
    A sequence of characters that defines a search pattern for text
  2. 2What does '.' (dot) match?
    Any single character except newline
  3. 3What does '^' match?
    The beginning of a line or string
  4. 4'*' quantifier
    Matches 0 or more occurrences of the preceding element
  5. 5{n} quantifier
    Matches exactly n occurrences of the preceding element
  6. 6{n,m} quantifier
    Matches between n and m occurrences of the preceding element
  7. 7'|' (pipe)
    Acts as an OR operator: matches either the pattern before or after
  8. 8What does '\d' match?
    Any digit (0-9)
  9. 9What does '\w' match?
    Any word character (alphanumeric + underscore)
  10. 10What does '\s' match?
    Any whitespace character (space, tab, newline)
  11. 11What does '\b' match?
    A word boundary (position between word and non-word character)
  12. 12Square brackets [ ]
    Define a character class: matches any one character inside the brackets
  13. 13What does [a-z] match?
    Any lowercase letter from a to z
  14. 14What does [0-9] match?
    Any digit from 0 to 9
  15. 15What does [^abc] match?
    Any character except a, b, or c (negation)
  16. 16Parentheses ( )
    Create a capturing group for extracting matched substrings
  17. 17'\' (backslash)
    Escapes special characters to match them literally
  18. 18Match a literal dot
    Use \. to escape the dot metacharacter
  19. 19Greedy quantifier
    Matches as much as possible (default behavior: *, +, {n,m})
  20. 20Lazy/non-greedy quantifier
    Matches as little as possible: use ? after quantifier (*?, +?, {n,m}?)
  21. 21What does \n match?
    A newline character
  22. 22What does \t match?
    A tab character
  23. 23What does \r match?
    A carriage return character
  24. 24Lookahead assertion
    Matches a pattern only if followed by another pattern: (?=...)
  25. 25Negative lookahead
    Matches a pattern only if NOT followed by another pattern: (?!...)
  26. 26Lookbehind assertion
    Matches a pattern only if preceded by another pattern: (?<=...)
  27. 27Negative lookbehind
    Matches a pattern only if NOT preceded by another pattern: (?<!...)
  28. 28How to match an email pattern?
    Common pattern: [a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}
  29. 29How to match a URL pattern?
    Simple pattern: https?://[^\s]+
  30. 30How to match a phone number?
    Example: \d{3}-\d{3}-\d{4} for format like 123-456-7890

And 53 more cards. Study the whole deck free

Articles about this deck

More Programming decks

See all
Study all 83 cards free