I am trying to extract a part of string prior to substring:
print(re.sub(r"(.*)b.*", r"1", 'abnc')) # anc
I would expect to get a
, but I am getting anc
.
Why is it?
In my view the pattern definitely can not match anything after b
.
I am trying to extract a part of string prior to substring:
print(re.sub(r"(.*)b.*", r"1", 'abnc')) # anc
I would expect to get a
, but I am getting anc
.
Why is it?
In my view the pattern definitely can not match anything after b
.