Regular Expressions 101

Community Patterns

Python Print String arg extraction

1

Regular Expression
Python

r"
(?:(?<=%\()|(?<={))([^\){]*)(?=[}\)])
"
gm

Description

Extract substitution parameters from python print strings works with

  • fstrings
  • old style format strings
  • old style %(variable) strings
Submitted by Giles Knap - 7 months ago