pattern matching

Pattern matching consists of finding a section of text that is matched by a regular expression. The underlying code that searches the text is the regular expression engine.
* The earliest (leftmost) match wins. Regular expressions are applied to the input starting at the first character and proceeding toward the last. As soon as the regular expression engine finds a match, it returns.
* Standard quantifiers are greedy. Quantifiers specify how many times something can be repeated. The standard quantifiers attempt to match as many times as possible. They settle for less than the maximum only if this is necessary for the success of the match. The process of giving up characters and trying less-greedy matches is called backtracking.