Python --Find out number of groups in the regex expression

Ref:

import re

def num_groups(regex):
    return re.compile(regex).groups

some_regex_str = 'miehaha_([A-Za-z0-9_-]+)'
print num_groups(some_regex_str)  # output: 1

Recommended Posts

Python --Find out number of groups in the regex expression
Maya | Find out the number of polygons in the selected object
Find out the apparent width of a string in python
Output the number of CPU cores in Python
Find the number of days in a month
Find the divisor of the value entered in python
Find the solution of the nth-order equation in python
Find the difference in Python
How to get the number of digits in Python
Find out the location of Python class definition files.
Get the size (number of elements) of UnionFind in Python
[Completed version] Try to find out the number of residents in the town from the address list with Python
Get the number of specific elements in a python list
[Homology] Count the number of holes in data with Python
Find out the maximum number of characters in multi-line text stored in a data frame
I used Python to find out about the role choices of the 51 "Yachts" in the world.
Find the eigenvalues of a real symmetric matrix in Python
[Python] Programming to find the number of a in a character string that repeats a specified number of times.
Count the number of Thai and Arabic characters well in Python
Find out the age and number of winnings of prefectural governors nationwide
[Python] Let's reduce the number of elements in the result in set operations
Get the number of readers of a treatise on Mendeley in Python
The result of installing python in Anaconda
The basics of running NoxPlayer in Python
In search of the fastest FizzBuzz in Python
Project Euler # 17 "Number of Characters" in Python
Get the number of searches with a regular expression. SeleniumBasic VBA Python
How to find out the number of CPUs without using the sar command
Check the in-memory bytes of a floating point number float in Python
[Python] Calculate the number of digits required when filling in 0s [Note]
Find out the name of the method that called it from the method that is python
[Python] Sort the list of pathlib.Path in natural sort
Get the caller of a function in Python
Match the distribution of each group in Python
Calculate the total number of combinations with python
Make a copy of the list in Python
The story of reading HSPICE data in Python
[Note] About the role of underscore "_" in Python
About the behavior of Model.get_or_create () of peewee in Python
Solving the equation of motion in Python (odeint)
Output in the form of a python array
Find out the day of the week with datetime
Find the geometric mean of n! Using Python
[Python] Find the transposed matrix in a comprehension
python xlwings: Find the cell in the last row
plot the coordinates of the processing (python) list and specify the number of times in draw ()
How to find out what kind of files are stored in S3 in Python
Divides the character string by the specified number of characters. In Ruby and Python.
Set an upper limit on the number of recursive function iterations in Python
Visualize the timeline of the number of issues on GitHub assigned to you in Python
How to find the coefficient of the trendline that passes through the vertices in Python
Find the maximum Python
the zen of Python
List find in Python
Regular expression in Python
Regular expression in Python
Prime number 2 in Python
Check if the string is a number in python
python beginners tried to predict the number of criminals
Experience the good calculation efficiency of vectorization in Python
[Python] A program that counts the number of valleys