"Another example could be" - Just those words made me think you are not only interested in v
or /
but any type of character that surrounds a string of interest. Therefor you could try a pattern like:
^(.)(.+)\1$
Or if you want to define the possibilities:
^([\/v])(.+)\1$
This way you would capture the first character in a capture group that you can refer to later down the line. You don't need to distinquish between v
or /
or any character perse. Now grab group 2 from a search result, e.g.:
import re
s = 'vHELLOv'
print(re.search(r'^(.)(.+)\1$', s).group(2))
returns:
HELLO