Frage

What is the difference between (a|b)* and a*b*? Can you show more examples of Kleene star and patterns? I've searched so many sites in Google, but it returns very little results on this topic. I would be very grateful as I am trying to understand how PHP regular expressions work.

War es hilfreich?

Lösung

(a|b)* means "a or b, any number of times". a*b* means "Any number of a's then followed by any number of b's". So there exist strings ("baa", "abba", etc) that match the first, but not the second.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top