Regular Expressions

Even though the walk-through earlier in this chapter used Wildcards in the example, the Regular Expressions (regex) offers the greatest degree of power and flexibility. Wildcards pattern syntax quickly becomes limiting when you start creating useful rules. This is where regex takes over. Regex is the default syntax, or it can be specified explicitly in the rule with a pattern syntax of ECMAScript.

Note
Throughout this chapter, the term Regular Expressions is used when referring to the URL Rewrite syntax choice. However, the actual syntax is lovingly referred to as regex by most heavy users of regular expressions. When discussing regular expressions in general, we'll use the term regex, although both can be used interchangeably.

Regex offers a powerful way to match strings with certain patterns to see if they match—and if they do, to highlight useful information into what is called a back-reference to be used later.

However, when IT people hear the term “regular expressions” (or “regex”), it's not uncommon for their face to pale and their knees to buckle. Regex is one of the most concise, cryptic, and difficult to understand syntaxes that an IT pro has to work with. Unless you've worked with it enough to get a good feel for it, it can be overwhelming. There is nothing intuitive about regex.

Note
Regular Expressions take more computing power than Wildcards or static values, so if you are really driving for high end performance, you may want to use ...

Get Professional Microsoft IIS 8 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.