Enter your regex: a?
Enter input string to search: ababaaaab
I found the text "a" starting at index 0 and ending at index 1.
I found the text "" starting at index 1 and ending at index 1.
I found the text "a" starting at index 2 and ending at index 3.
I found the text "" starting at index 3 and ending at index 3.
I found the text "a" starting at index 4 and ending at index 5.
I found the text "a" starting at index 5 and ending at index 6.
I found the text "a" starting at index 6 and ending at index 7.
I found the text "a" starting at index 7 and ending at index 8.
I found the text "" starting at index 8 and ending at index 8.
I found the text "" starting at index 9 and ending at index 9.
Enter your regex: a*
Enter input string to search: ababaaaab
I found the text "a" starting at index 0 and ending at index 1.
I found the text "" starting at index 1 and ending at index 1.
I found the text "a" starting at index 2 and ending at index 3.
I found the text "" starting at index 3 and ending at index 3.
I found the text "aaaa" starting at index 4 and ending at index 8.
I found the text "" starting at index 8 and ending at index 8.
I found the text "" starting at index 9 and ending at index 9.
Enter your regex: a+
Enter input string to search: ababaaaab
I found the text "a" starting at index 0 and ending at index 1.
I found the text "a" starting at index 2 and ending at index 3.
I found the text "aaaa" starting at index 4 and ending at index 8.
上記の例は、
Java Documentation
数量詞からのものです。上記の例から私が理解していることから、貪欲な数量詞がどのように機能するかを次に示します。
?と *
言及されたキャラクターの不在の存在を探します。それらの前の文字が見つからない場合は、その場所を長さゼロの一致としてマークします。
*
グループに行く間、文字ごとの一致に?
行きます。
+
+
正規表現のグループマッチングによってグループ化されます。長さゼロの一致は行われません。
私の質問は次のとおり
です。数量詞の理解は正しいですか、それとも何かを台無しにしていますか?
また、Java正規表現の頭脳に優しいガイドはありますか(Googleには初心者を対象としたガイドはありません)?