Pergunta

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.

Foi útil?

Solução

(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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top