Python coding : get string between two characters

I want to get a substring between two characters (/ and ?) from some url I have
For example, I have : and I need to have just “centre-de-vaccination-covid-19-rennes-school-of-business-rennes”

I tried with split(’/, ?’) and split(’/’, ‘?’) but it doesn’t work

Take a look at regular expressions (the re module). They allow you to specify a pattern and match a string or parts of it against that pattern:

>>> import re
>>> url = ''
>>> r = re.compile(r'/([^/\?]+)\?')
>>> m =

The exact pattern depends on what exactly you’re looking for, the one I wrote searches for a /, a group of one or more characters that aren’t / or ?, and finally a ?. The group is defined by parentheses, and is helpful because you can access matched groups in the Match object (m here).

text = ""

parts1 = text.split('?')
parts2 = parts1[0].split('/')