Q: I need a regex to find a phrase between two tags python I have two labels that tell me what type the phrase is, and I need to find them in a phrase and extract the phrase from within them, and their positions
Phrase example:
"Hello, my name is TYPE_PER María Pérez END_TYPE and I'm from TYPE_LOC Europe END_TYPE"
I want you to extract the phrase "María Pérez" What is between TYPE_PER and END_TYPE

A: I'll do you one better and find all the TYPE_* tags and their values:
>>> import re
>>> s = "Hello, my name is TYPE_PER María Pérez END_TYPE and I'm from TYPE_LOC Europe END_TYPE"
>>> dict(re.findall("(TYPE_[A-Z]+)\s*(.+?)\s*END_TYPE", s))
{'TYPE_PER': 'María Pérez', 'TYPE_LOC': 'Europe'}


A: .splite() use
text = "Hello, my name is-María Pérez-and I'm from-Europe-"

test = text.split('-')

for i in range(int(len(test)/2)):
    print(test[i*2+1])

