Regular Expressions 101

Community Patterns

Parsing text between '[' and ']' unlimited number of times

0

Regular Expression
Python

r"
(\[.*?\])
"
gm

Description

Using capturing group to match any text between [ and ]

Test string

'([Total Revenue] + [COGS] + [Distribution Costs] + [Sales Force Costs] + [A&P Costs] + [NDA Affairs Costs] + [Other Operating Costs]) * - [NDA share]'

Submitted by anonymous - 2 years ago