The regexp is
^[^\d]*?(\d+)[^\d]*?(\d+)?[^\d]*?$
Am I understanding this right? The ^
and $
at the beginning and end of this expression set the start and endpoints for the expression (meaning that it should be an exact match?). Then inside it's expecting 2 series of non-digits that is followed by any number of digits, and then ends with any non-numeric character?
For example: "My mom has 6 cats and 1 dog."
Also, could somebody please explain the purpose of using capture groups ()
vs the list []
in this expression?
I apologize if I'm answering my own question, I just want to make sure I'm understanding this.