Non-capturing group vs named group | SoloLearn: Learn to code for FREE!

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>

1/14/2017 9:23:48 PM

Matt B

3 Answers

New Answer

+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)