First, I know x(?=y)
Matches 'x'
only if 'x'
is followed by 'y'
.
But, when I try
r'^(?=.*[0-9])(?=.*[a-z])'
,- why both
0a
anda0
match? - Why the order is not important at all?
- For
0a
, what it matches?- If it matches the empty string before
0
, it should fail the second condition(?=.*[a-z])
because the empty string before0
followed by0
, but nota-z
. - If it matches
0
because it followed bya
, it should fail the first condition, because0
not followed by[0-9]
. - I don't know what's wrong with the way I think. And I am not sure if I express myself clear so that you can understand what I mean..
- If it matches the empty string before
- why both
and for
r'^(?=.*[0-9])(?=.*[a-z])$'
, if the above situation without$
works, why not this one? I fail to figure out what this matches. It seems it does not match anything.
Thanks a lot for your help.