The Greedy, the Lazy and the Ugly

Report a typo

Suppose we have a string:

string = "123abc456"

Match the template with the matching substring of this string (if there are several matching substrings for a template, find the one closest to the beginning of the string).

Tip: Remember that \d means any digit, . stands for any character, * is used for zero or more occurences, + for one or more, and ? makes the quantifier "lazy".

Match the items from left and right columns
\d.*\d
\d.*?\d
\d.+?\d
\d.{5}\d
12
123
123abc456
123abc4
___

Create a free account to access the full topic