2

I am learning re in python.
I understand all other things in the following example.
but, i really dont understand what special (in tags) means in the following example.

re.compile('((?P<special>[0:-])\s)')

kindly help if know it.

2 Answers 2

5

They're called named capturing groups.

A quick explanation here:

Python's regex module was the first to offer a solution: named capture. By assigning a name to a capturing group, you can easily reference it by name. (?P<name>group) captures the match of group into the backreference "name". You can reference the contents of the group with the numbered backreference \1 or the named backreference (?P=name).

Sign up to request clarification or add additional context in comments.

Comments

2

This is called Named Capture Group.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.