0

I have have the following strings

s1 = "/url/{part}"
s2 = "/url/{code}"

How can I extract the named arguments from the above strings, and get part and code?

Tomerikoo
  • 15,737
  • 15
  • 35
  • 52
user1187968
  • 5,950
  • 15
  • 62
  • 136
  • 2
    A regular expression that matches everything from `{` to `}` would be a simple way to do it. – Barmar Mar 05 '21 at 19:57
  • Just for fun, see https://repl.it/@JustinEzequiel/EnchantingUpbeatLinuxpc for an alternative that uses `str.format` and catches the `KeyError`. Not recommended for production use. – Justin Ezequiel Mar 05 '21 at 20:13

0 Answers0