Python coding : get string between two characters #21422
-
I want to get a substring between two characters (/ and ?) from some url I have I tried with split(’/, ?’) and split(’/’, ‘?’) but it doesn’t work |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Take a look at regular expressions (the
The exact pattern depends on what exactly you’re looking for, the one I wrote searches for a |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
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: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 be…