I am able to understand output of the below command:
import re
text = "streets2345"
pattern = r"\d+"
match = re.search(pattern, text)
print(match.group(0))
Output: 2345
However, I am not able to understand why the below code is returning null
.
import re
text = "streets2345"
pattern = r"\d*"
match = re.search(pattern, text)
print(match.group(0))
Output: null
Here, the first character s
of the text matches the pattern \d*
.
So, why the output is not s
instead of null
?