Java SE RegEx

Print the objectives

Take the exam   Take a beta test

This exam tests knowledge of the Java implementation of regular expressions (RegEx). The focus is on writing and interpreting RegEx patterns, not the specifics and peculiarities of the Matcher and Pattern classes. Matchers and Patterns may appear in code snippets, but the details of these classes are out of scope.

The exam is not about throwing hugely complex patterns at you and expecting you to perform as a human Matcher.

The best and clearest RegEx reference is Mastering Regular Expressions (3rd edition) by Jeffrey Friedl, which includes a chapter on Java's RegEx implementation.

A more compact but less exhaustive reference is the Regular Expressions section of the Essential Classes trail on the Java Tutorials site. A handy quick reference is the JavaDocs for the java.util.regex.Pattern class.

  Released  Beta  Frozen  

Special Characters  2 questions

  • Describe the purpose of metacharacters.
  • Place backslashes, tabs, line-feeds and carriage-returns into patterns.
  • Interpret patterns containing these metacharacters: ^, $, ?, *, +
  • Use metacharacters as literal characters in patterns (escaping).
14 85 25

Character Classes  2 questions

  • Explain what a character class is.
  • Use appropriate metacharacters to implement negation (^), ranges (-), unions (nested classes), intersections/subtractions (&&).
  • Name and use the predefined character classes: ., \d, \D, \s, \S, \w, \W.

(Out of scope: POSIX character classes, java.lang.Character classes, Classes for Unicode blocks and categories)

17 80 10

Boundary Matchers  2 questions

  • Employ these boundary matchers in patterns: \b, \B, \A, \G, \Z, \z.
12 19 15

Quantifiers  2 questions

  • Explain the differences between greedy, reluctant and possessive quantifiers.
  • Recognise which parts of a pattern request greedy, reluctant or possessive searches.
18 20 18

Grouping  2 questions

  • Create "sub-patterns" within a pattern using grouping.
  • Know how capturing groups are numbered; identify a capturing group by its number.
  • Explain the difference between capturing and non-capturing groups.

(Out of scope: back references)

12 14 19

Exam information

  • 15 minutes
  • 10 questions (378)
  • 80% required
  • +2 √
  • - 8  points
  • 15 day delay
  • status: released

Exam leader