0
Non-capturing group vs named group
Why would one use a named non-capturing group rather than a named group? The example gives ?:def but I fail to see how this is a better way of doing it rather than giving it a name such as <first>
3 Respostas
+ 1
Never mind, looked at tut comments.
0
Just remember that the method groups() returns all groups up from 1
0
import re
num = "07987549836"
pattern = r"9"
num = re.sub(pattern, "0", num)
print(num)