My understanding *is that it consumes as many characters as possible (eagerly), but "returns if necessary." Therefore, in a*a+, a*returns one (or more?) Character in a+so that it can match.
*
a*a+
a*
a+
However, in (a{2,3})*, why does the first “instance” a{2,3}not give a character to the second “instance”, so the second can match?
(a{2,3})*
a{2,3}
In addition, the (a{2,3})*a{2,3}first part seems to give the symbol of the second part.
(a{2,3})*a{2,3}
aaaa ^(a{2,3})*$.
aaaa
^(a{2,3})*$
, :
(a{2,3})* , , .
. .
, . a{2,3} aa aaa. aaaa (a{2,3})*, aaa. a{2,3}, a. , regex- a{2,3}, . aaa , regex .
aa
aaa
a
$ , , . , (a{2,3})*a{2,3} .
$
:
* , (), ""
. , .
" ". .
, .
a*a+ - a, a
(a{2,3})*a{2,3} - a, , a (: , , " ", )
(a{2,3})* - a ( , a a )
backtracking is only performed if a match is not performed, but aaais a valid match, a negative lookahead (?!a)can be used to prevent matching from matching a.
(?!a)
compare
(aaa?)*
and
(aaa?)*(?!a)
Source: https://habr.com/ru/post/1691662/More articles:Why is MAX working on a column in the middle of the index - mysqlC # LINQ query creating inefficient SQL compared to the original query - c #Could not resolve service for type IOptions [DataAccessConfiguration] in nonASP.NET Core application - c #C # intellisense not working in VS Code - c #How to detect an update when an RPM is installed that deprecates another RPM - rpmDoes it make sense to detect an inline CSS style that doesn't need to be used or empty? - javascriptPython (Fibo series): trying to understand the difference between a, b = b, a + b OR a = b & a = a + b - pythonWhen you press the div button, display 1 on 1 (one at a time) - javascriptКласс, который реализует ArrayAccess, вызывает Fatal Error, если не задан первый - oopRegex, how to match agreed tags? - pythonAll Articles