Table of Contents

Regular Expression - (Lazy|Reluctant) Quantifier

About

A Lazy quantifier will match the shortest possible string. Match as few as possible, repeat as few times as possible whereas a Greedy quantifier will match the longest possible string.

Syntax

To make a match lazy, you add a question mark after the greedy quantifier.

List

Lazy Quantifier Description
X?? X, once or not at all
X*? X, zero or more times
X+? X, one or more times
X{n}? X, exactly n times
X{n,}? X, at least n times
X{n,m}? X, at least n but not more than m times

Example

Hello World

For example in the termhello

HTML

<em>Hello World</em>

Documentation / Reference