Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Regular expressions are often messy and confusing. There’s no denying it—regular expressions have a very compact and visually distracting appearance. They are a “little language” unto themselves. However, this little language isn’t made up of words like foreach and while. Instead, it uses atoms like \w, [a-z], and +.
The concept of regular expressions is confusing all by itself. Ordinary programming chores generally translate more-or-less directly into code. You might think “count from 1 to 10,” and write a foreach loop like the following: