

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to get the number of capture groups in Python regular expression?
The following code gets the number of captured groups using Python regex in given string
Example
import re m = re.match(r"(\d)(\d)(\d)", "632") print len(m.groups())
Output
This gives the output
3
- Related Questions & Answers
- Counting the number of groups Java regular expression
- Named capture groups JavaScript Regular Expressions
- How to capture an exception raised by a Python Regular expression?
- How do we use Python Regular Expression named groups?
- How do you access the matched groups in a JavaScript regular expression?
- How to optimize the performance of Python regular expression?
- Regex - reusing patterns to capture groups in JavaScript?
- How to extract floating number from text using Python regular expression?
- How to write a Python regular expression to get numbers except decimal?
- How to write Python regular expression to get all the anchor tags in a webpage?
- How to write Python Regular Expression find repeating digits in a number?
- How to use wildcard in Python regular expression?
- How to use range in Python regular expression?
- How to use variables in Python regular expression?
- How to match parentheses in Python regular expression?
Advertisements