Effective ways of teaching regex to students who know Java
Many students find them difficult and intimidating.


Then the challenge is to make them fun and engaging and (ideally) interactive. I myself have undertaken the challenge here and there of teaching myself regex, and two resources rose to the top in my own learning: RegexOne and Regex Crossword.

RegexOne is great as a lesson-by-lesson tutorial. Students can type and see in real time what tests cases their regex does/does not match. There are 15.5 lessons and 8 practice problems. The practice problems draw from relevant use cases, such as extracting a phone number, trimming white space, or reading a log file.

Regex Crossword mixes regex with logic: students have to fill in a square grid and track how gradually more complex regular expressions interact with each other. (That sounds a bit vague, but an example like this one makes it clear what I mean.) The crosswords tend to have fun themes/solutions. There are many crosswords to solve, including ones with great complexity, so students will have to spend lots of time working at it if they'd like to complete all the puzzles. 

When it comes to working in class, it'd be pretty easy to work with some of the smaller crosswords in a non-digital manner. You could put one on the board at the start of every class as a warm-up or print/copy some of your favorite from the site. Maybe even have students work in groups and complete to solve a series of puzzles in the fastest possible time.

Between these two resources, students will at least have a pretty good start to working with regex.