regex * vs + puzzle

the case

  • What does it mean that you can match the string + you qualify on the preceding expression
  • What does it mean that a* = a{0,} and a+ = a{1,}

solution

Each of them is a quantifier

  • the star quantifier (*) means that the preceding expression can match zero or more times
    • it is same as {0,}
  • the plus quantifier (+) indicates that the preceding expression MUST match at least one time or multiple times and
    • it is same as {1,} .
regex * quantifier
regex * quantifier
regex + quantifier
regex + quantifier

Leave a Reply

Your email address will not be published. Required fields are marked *