remram44 / regex-cheatsheet

Cheatsheet for different regex syntaxes
https://remram44.github.io/regex-cheatsheet/regex.html
278 stars 64 forks source link

Multiplicity #17

Closed lamyergeier closed 6 years ago

lamyergeier commented 6 years ago

How 0 or 1 is different from 0 or 1, (non-greedy) ?

remram44 commented 6 years ago

Non-greedy means that if they are multiple ways it can match, it will consume fewer characters rather than more characters. This usually only makes a difference when you're using captures, because otherwise you don't care how it matches.

Example (where +? is the non-greedy version of +):