For regular expressions, it is often desirable to make part of the expression non-greedy. For this, we use the question mark.
What is the difference between (.*?) and (.*)? when used as part of a larger expression in order to capture zero or more characters?
For example, will: (.*?)ng ever yield a different result than (.*)?ng ?
The end results are the same (confirmed by https://regex101.com/), but are there differences that are not so obvious?
No comments:
Post a Comment