Effective ways of teaching regex to students who know Java My students are knowledgeable about Java but need to know something about Regular Expressions. Many students find them difficult and intimidating. The students don't need to know every detail, but do need to know enough to work effectively and learn more. 

What are effective ways of teaching the fundamentals of regular expressions in Java or otherwise? I'd like the students to understand how it works, and not only what each pattern does.



This year it's been decided at my school (I'm a teacher assistant this year) to teach the students a bit about regular expressions. We teach in Java.
The students have never faced anything like regex in the past. The students I've asked (we have a test group - we test new ideas on them for feedback. A diverse group in terms of level and background1 consisting of 3-4 students) seem to find regex very difficult (we just gave them the pattern list and explain each pattern).



1background in terms of knowledge in the field.
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.