English | česky | >> Deutsch << | Español ZVON > Tutorials > Regular Expressions Tutorial
>> Beispiel 17 << | Zurück | Vor | Inhalt | Reguläre Ausdrücke

Beschreibung


Standardmässig erzielt jedesTeilmuster soviele Treffer, wie nur möglich. Dieses Verhalten ändert sich, wenn dem Quantifizierer ein Fragezeichen folgt. Vergleiche "*" (Fall 1) mit "*?" (Fall 2), "+" (Fall 3) mit "+?" (Fall 4), und "?" (Fall 5) mit "??" (Fall 6).

Quellcode


One ring to bring them all and in the darkness bind them

Fall 1


Regulärer Ausdruck: r.*
Erster Treffer:One ring to bring them all and in the darkness bind them
Alle Treffer:One ring to bring them all and in the darkness bind them

Fall 2


Regulärer Ausdruck: r.*?
Erster Treffer:One ring to bring them all and in the darkness bind them
Alle Treffer:One ring to bring them all and in the darkness bind them

Fall 3


Regulärer Ausdruck: r.+
Erster Treffer:One ring to bring them all and in the darkness bind them
Alle Treffer:One ring to bring them all and in the darkness bind them

Fall 4


Regulärer Ausdruck: r.+?
Erster Treffer:One ring to bring them all and in the darkness bind them
Alle Treffer:One ring to bring them all and in the darkness bind them

Fall 5


Regulärer Ausdruck: r.?
Erster Treffer:One ring to bring them all and in the darkness bind them
Alle Treffer:One ring to bring them all and in the darkness bind them

Fall 6


Regulärer Ausdruck: r.??
Erster Treffer:One ring to bring them all and in the darkness bind them
Alle Treffer:One ring to bring them all and in the darkness bind them