Regex please ! The asterex the star character

If the asterex * matches zero or more matches, how does it match a zero match which is a no match?
Sorry but i’m still confused, i watched a vid on youtube about it and they just repeated the expression “zero or more”.

Let’s say you have ba* (match a ‘b’ followed by zero or more 'a’s)

  • “b” would match that pattern because it is a ‘b’ followed by zero 'a’s
  • “ba” would match because it is a ‘b’ followed by one ‘a’
  • “baa baa black sheep” would have three matches: “baa” (‘b’ followed by two ‘a’s), “baa” (the second one’), and “b” from “black” (‘b’ followed by zero 'a’s)
1 Like

i discovered this before but when i used the + character for one or more matches, as i do like to experiment with things, i got confused. now i tryed both + and * separatly and you turned out to be right.
thank you.

I’m glad I could help. Experimenting with different patterns is often the only way to really get a grasp on this, so you’re doing great.

1 Like