DocWiki
DocWiki

Reputation: 3584

Difference between (.+?) and (.*?) in regular expressions

I would like to know what the difference is between (.+?) and (.*?)

Upvotes: 12

Views: 18436

Answers (1)

Jeremiah Willcock
Jeremiah Willcock

Reputation: 30969

The .+? form requires at least one character to match, while .*? can match none at all. Both operations are non-greedy, so they will try to find the shortest possible matching string.

Upvotes: 27

Related Questions