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>

14th Jan 2017, 9:23 PM
Matt B
3 Antworten
+ 1
Never mind, looked at tut comments.
14th Jan 2017, 11:10 PM
Matt B
0
Just remember that the method groups() returns all groups up from 1
23rd Jan 2017, 5:07 PM
George Abinader
George Abinader - avatar
0
import re num = "07987549836" pattern = r"9" num = re.sub(pattern, "0", num) print(num)
23rd Jan 2017, 7:49 PM
Crystal Marie
Crystal Marie - avatar