Tech
Greedy vs. Non-Greedy Regex: Why the Same Pattern Can Match Differently
A regex quantifier like * or + means "the preceding element can repeat any number of times," but how much it actually matches depends on whether the engine tries to match as much as possible or as little as possible. That's the greedy vs. non-greedy distinction, and adding a single ? to a quantifier can produce a completely different result. This post works through that distinction using real parsing code from this app's WP-CLI output handling.
Quantifiers Are Greedy by Defau...
Read the full discussion on Dev.to
This article was aggregated from Dev.to. Click to join the conversation.
View on Dev.to