SyntaxFix
Write A Post
Hire A Developer
Questions
I know this is a little old, but this but here is a concise function for counting regex patterns.
def regex_cnt(string, pattern): return len(re.findall(pattern, string)) string = 'abc123' regex_cnt(string, '[0-9]')