How Do Capture Groups Work? (wrt Python Regular Expressions)
While using regex to help solve a problem in the Python Challenge, I came across some behaviour that confused me. from here: (...) Matches whatever regular expression is inside the
Solution 1:
Because you only have one capturing group, but it's "run" repeatedly, the new matches are repeatedly entered into the "storage space" for that group. In other words, the 1
s were lost when they were "overwritten" by subsequent 1
s and eventually the 2
.
Post a Comment for "How Do Capture Groups Work? (wrt Python Regular Expressions)"