Regex matching 3rd word in a line? - Python.
A regular expression is a way to match text patterns. It is specified with a string and is compiled to a regular expression object that can be used for searching and other pattern-using operations. Patterns can get pretty complicated and are not limited to exact string matches (but for now we'll stick with exact string matching since it's easy to understand).
Because Regex objects are immutable, this is a one-time procedure that occurs when a Regex class constructor or a static method is called. To eliminate the need to repeatedly compile a single regular expression, the regular expression engine caches the compiled regular expressions used in static method calls. As a result, regular expression pattern-matching methods offer comparable performance.