5 Easy, difficult, and impossible tasks
Some things are difficult or impossible with regular expressions, and many are elegant and highly expressive. The puzzles in this chapter ask you to think about which situation each puzzle describes.
Puzzle 18 Identifying equal counts
Summary In this puzzle we would like to balance starting and ending symbols.
At times we encounter a message or a stream that uses balanced “increment” and “decrement” symbols. For example, one way to check that a message has terminated might be to match up the increments and decrements. The same concept would apply to many kinds of messages and symbols—perhaps you would like to set the table with the same number of forks and knives, for example.
As a simplification of ...
Get Regular Expression Puzzles and AI Coding Assistants now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.