* + Qualifiers are greedy because they match as much text, only if they are followed by a? Can be achieved non-greedy or minimal match.
text:
<H1> describes a regular expression - Chapter. 1 </ H1>
: Greedy everything between the start from the following expression matches less than symbol (<) to the closed H1 tag is greater than symbol (>).
/<.*>/
non-greedy: If you only need to match the beginning and end of H1 tag, the following non-greedy expression matches only <H1>.
/<.*?>/
If you want to H1 tag match began, the expression is:
/ <\ W +?> /
the PS: by *, + or ? qualifiers placed after the transition from the Expressions "greedy" to "non-greedy" or minimum matching expression?.
PS: Regular expression online test: https://c.runoob.com/front-end/854
PS:
About grep pattern of non-greedy
than text, for example
Grep can be used in perl syntax, so grep -P
you can work, but grep -E
it is the same, egrep
does not work (it would be greedy).
See also: HTTP : //blog.vinceliu.com/2008/02/non-greedy-regular-expression-matching.html