Regular Expressions 101

Community Patterns

Match function declerations in python

1

Regular Expression
Python

r"
.*def[\s\\]*?(\w+)[\s\\]*?\(([\w\W]*?)\)(?:[\s\\]*?->[\s\\]*?([\w\(\)\[\]\,]+))?[\s\\]*?:
"
gm

Description

This regex will match function declerations in python

Submitted by danielnachumdev - 14 days ago