• Home
  • Whiteboard
  • Online Compilers
  • Practice
  • Articles
  • AI Assistant
  • Jobs
  • Tools
  • Corporate Training
  • Courses
  • Certifications
Login
    • Java
    • JSP
    • iOS
    • HTML
    • Android
    • Python
    • C Programming
    • C++ Programming
    • C#
    • PHP
    • CSS
    • Javascript
    • jQuery
    • SAP
    • SAP HANA
    • Data Structure
    • RDBMS
    • MySQL
    • Mathematics
    • 8085 Microprocessor
    • Operating System
    • Digital Electronics
    • Analysis of Algorithms
    • Mobile Development
    • Front End
    • Web Development
    • Selenium
    • MongoDB
    • Computer Network
    • General Topics
  • Library
  • Courses
  • Certifications
  • Login
  • SQL
  • HTML
  • CSS
  • Javascript
  • Python
  • Java
  • C
  • C++
  • PHP
  • Scala
  • C#
  • Tailwind CSS
  • Node.js
  • MySQL
  • MongoDB
  • PL/SQL
  • Swift
  • Bootstrap
  • R
  • Machine Learning
  • Blockchain
  • Angular
  • React Native
  • Computer Fundamentals
  • Compiler Design
  • Operating System
  • Data Structure and Algorithms
  • Computer Network
  • DBMS
  • Excel
Technical Questions and Answers
  • Data Structure Data Structure
  • Networking Networking
  • RDBMS RDBMS
  • Operating System Operating System
  • Java Java
  • MS Excel MS Excel
  • iOS iOS
  • HTML HTML
  • CSS CSS
  • Android Android
  • Python Python
  • C Programming C Programming
  • C++ C++
  • C# C#
  • MongoDB MongoDB
  • MySQL MySQL
  • Javascript Javascript
  • PHP 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

Get the Number of Capture Groups in Python Regular Expression

PythonServer Side ProgrammingProgramming


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
Rajendra Dharmkar
Rajendra Dharmkar

Updated on: 2020-02-20T07:57:19+05:30

2K+ Views

  • Related Articles
  • Counting the number of groups Java regular expression
  • Named capture groups JavaScript Regular Expressions
  • How do we use Python Regular Expression named groups?
  • How to capture an exception raised by a Python Regular expression?
  • How do you access the matched groups in a JavaScript regular expression?
  • How to optimize the performance of Python regular expression?
  • How to validate MasterCard number using Regular Expression?
  • How to validate CVV number using 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 find repeating digits in a number?
  • Regular Expression Matching in Python
  • Regular Expression Modifiers in Python
  • Regular Expression Patterns in Python
Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements
TOP TUTORIALS
  • Python Tutorial
  • Java Tutorial
  • C++ Tutorial
  • C Programming Tutorial
  • C# Tutorial
  • PHP Tutorial
  • R Tutorial
  • HTML Tutorial
  • CSS Tutorial
  • JavaScript Tutorial
  • SQL Tutorial
TRENDING TECHNOLOGIES
  • Cloud Computing Tutorial
  • Amazon Web Services Tutorial
  • Microsoft Azure Tutorial
  • Git Tutorial
  • Ethical Hacking Tutorial
  • Docker Tutorial
  • Kubernetes Tutorial
  • DSA Tutorial
  • Spring Boot Tutorial
  • SDLC Tutorial
  • Unix Tutorial
CERTIFICATIONS
  • Business Analytics Certification
  • Java & Spring Boot Advanced Certification
  • Data Science Advanced Certification
  • Cloud Computing And DevOps
  • Advanced Certification In Business Analytics
  • Artificial Intelligence And Machine Learning
  • DevOps Certification
  • Game Development Certification
  • Front-End Developer Certification
  • AWS Certification Training
  • Python Programming Certification
COMPILERS & EDITORS
  • Online Java Compiler
  • Online Python Compiler
  • Online Golang Compiler
  • Online C Compiler
  • Online C++ Compiler
  • Online C# Compiler
  • Online PHP Compiler
  • Online MATLAB Compiler
  • Online Bash Compiler
  • Online SQL Compiler
  • Online Html Editor
  • ABOUT US |
  • OUR TEAM |
  • CAREERS |
  • JOBS |
  • CONTACT US |
  • TERMS OF USE |
  • PRIVACY POLICY |
  • REFUND POLICY |
  • COOKIES POLICY |
  • FAQ'S
tutorials point logo

Tutorials Point is a leading Ed Tech company striving to provide the best learning material on technical and non-technical subjects.

© Copyright 2025. All Rights Reserved.