Let’s say we want to match every number in a text. Numbers are made up of

one or more digits concatenated together. Using our basic regex symbols that would be any digit:

0 or 1 or 2 or 3 or 4 or 5 or 6 or 7 or 8 or 9, concatenated with zero or more of any digit:

0 or 1 or 2 or 3 or 4 or 5 or 6 or 7 or 8 or 9 star. Now this is*far*too long for a busy computer scientist. Thankfully, we can use some extended regex syntax

to describe this and others using only a few symbols. In many systems, a list of symbols between square brackets,

like [0,1,2,3,4,5] means “choose one from this list,” and we can shorten this further to [0-5],

which means “choose any symbol in the range 0 to 5.” But in our example, we want any single digit,

so we can use another code: backslash d (d). d(d)* is so much shorter now,

but it still matches exactly the same pattern! In fact we can shorten it even more

by introducing the plus notation. While A* matches zero or more As,

A+ matches one or more As. So we can now write our regex formula

that will match any number as (d)+. Other common symbols are: the question mark,

which matches an optional occurrence of the symbol; a number in curly braces, which matches exactly

that number of the previous symbol; and the period or full stop,

which matches any single character once. Remember, all of these extended regex symbols

may be pretty fancy, and they shorten things a lot. But they are really just shortcuts that could be

written longhand using the four basic symbols; bar, star and the parentheses.